Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: number format in graph labels


From   Gisella Young <[email protected]>
To   [email protected]
Subject   RE: st: number format in graph labels
Date   Wed, 13 Aug 2008 08:09:08 -0700 (PDT)

THANK YOU Martin and Nick for your helpful advice (although it does seem a bit more complicated than I had hoped!)

It occurs to me that a (hopefully) simpler way might just be to title the y-axis "Whatever (thousands)" or "Whatever ('000)" and then have the labels all divided by a thousand, so what would have been 1000000 would just be 1000, in which case the absence of spaces doesn't really matter as the smaller number of 0's is easy to see. However I'm not sure if there is an easy way of doing this (in my pre-Stata life I made a lot of graphs in Excel and there is an option to tick to show the graph scale in 100's, 1000's, etc). I don't want to actually divide my y variable by 1000 as i still want the original variable to be used in plotting the chart, but just want to show the variable graphically in '000's - is there a way to do this in Stata?

Sorry for the follow-up question, any suggestions would be most appreciated.

Gisella


--- On Tue, 8/12/08, Nick Cox <[email protected]> wrote:

> From: Nick Cox <[email protected]>
> Subject: RE: st: number format in graph labels
> To: [email protected]
> Date: Tuesday, August 12, 2008, 3:20 PM
> I think Martin is correct. So, you have to knit the thing
> yourself. 
> 
> The easiest trick I can think of is that you can use a
> format to put
> commas in the places where Gisella wants spaces, and then
> just
> substitute accordingly. 
> 
> Here is a demonstration program: 
> 
> *! 1.0.0 NJC Statalist 12 Aug 2008 
> program spacedoutnumbers
> 	version 8 
> 	numlist "`0'", int  
> 
> 	local inlist `r(numlist)' 
> 
> 	/// 42 is just an integer that should be big enough 
> 	foreach in of local inlist { 
> 		local out : di %42.0fc `in' 
> 		local out = trim("`out'") 
> 		local out : subinstr local out "," "
> ", all 
> 		local outlist `outlist' `in'
> "`out'"
> 	} 
> 
> 	di `"`outlist'"'  
> 	c_local mylab `outlist' 
> end
> 
> If you type an integer numlist at this program, it emits a
> local in the
> calling program's space called mylab that contains all
> the information
> you want for an axis label option. 
> 
> It also displays the same stuff so that you can see that
> you have what
> you want. 
> 
> Thus suppose you want numbers 0 (100000) 1000000 spaced out
> in this way:
> 
> 
> . sysuse auto 
> 
> . spacedoutnumbers 0(100000)1000000
> 
> 0 "0" 100000 "100 000" 200000 "200
> 000" 300000 "300 000" 400000 "400
> 000" 50000
> > 0 "500 000" 600000 "600 000"
> 700000 "700 000" 800000 "800 000" 900000
> "900 00
> > 0" 1000000 "1 000 000"
> 
> . scatter mpg weight, yla(`mylab', ang(h))
> 
> This doesn't cope with non-integers. My guess is that
> Gisella would be
> most unlikely to want non-integers on the same graph. You
> may say what
> about logarithmic scales, but if Gisella's public has
> difficulty with
> large integers, I doubt that logarithmic scales are in
> mind. 
> 
> But you could add non-integers as further arguments to the
> axis label
> option. 
> 
> Nick
> [email protected] 
> 
> Martin Weiss
> 
> Well, any criticism connected with the labels would
> indirectly be  
> aimed at overall -format-ing in Stata.  If you
> 
> *********
> sysuse auto, clear
> replace price=10000*price
> twoway (scatter headroom price), xlabel(, format(%15.2fc))
> *********
> 
> there are no exponents in the resulting graph. I do not
> think that  
> gaps instead of commas to seperate thousands are possible
> with -format-.
> 
> Quoting Gisella Young <[email protected]>:
> 
> > I am trying to change the format of the labels
> (numbers) of a graph.  
> >  At the moment the numbers appear as e.g. 1000000 and
> to make it   
> > clearer I would like  them to appear as e.g. 1 000
> 000. I also don't  
> >  want to use exponents as I need to graphs to be
> easily accessible   
> > for a non-technical audience. I haven't found a
> way to do this in   
> > any FAQ or help file. I have tried options in the
> formatting of the   
> > labels such as ylabel(,  format(%9,0g) ) but without
> success. Any   
> > suggestions would be most welcome.
> >
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


      

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index