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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: number format in graph labels |

Date |
Tue, 12 Aug 2008 16:20:19 +0100 |

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 n.j.cox@durham.ac.uk 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 <gisellayoung@yahoo.com>: > 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/

**Follow-Ups**:**RE: st: number format in graph labels***From:*Gisella Young <gisellayoung@yahoo.com>

**References**:**st: number format in graph labels***From:*Gisella Young <gisellayoung@yahoo.com>

**Re: st: number format in graph labels***From:*Martin Weiss <martin.weiss@uni-tuebingen.de>

- Prev by Date:
**st: Computing interaction effects after svy:heckman** - Next by Date:
**st: RE: nl program conversion from Stata 8 to 9 or 10 including if statements** - Previous by thread:
**Re: st: number format in graph labels** - Next by thread:
**RE: st: number format in graph labels** - Index(es):

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