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

From |
vwiggins@stata.com (Vince Wiggins, StataCorp) |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Re: Reducing number of labels on bar graph |

Date |
Thu, 06 Nov 2003 13:52:02 -0600 |

David Epstein <de11@columbia.edu> asks about removing the labels from some of the bars on his bar graph, > I know this should be easy, but I'm stumped. I'm drawing a (oneway) > bar graph with 46 different categories. When stata puts them all on > the x-axis, they run into each other, so I'd like, for instance, to > only display numbers 1, 6, 11, etc. up to 46. How does one do this? Friedrich Huebler <huebler@rocketmail.com> suggests that we might be able to just set some labels to blank and gives the following example, > . sysuse auto > . graph bar mpg, over(make) > . graph bar mpg, over(make, relabel(1 "1" 2 " " 3 " " 4 " " 5 " " 6 > "6" 7 " " 8 " " 9 " " 10 " " 11 "11" 12 " " 13 " " 14 " " 15 " " 16 > "16")) The -relabel()- suboption is not so much specifying a specific label as it is giving an alternate label to be used in place of the numeric value for the category that would be shown if there were no label. Put another way, -graph bar- is dead set on labeling all bars or none of them. With so many categories, it may be preferable to treat the axis as continuous and use -twoway bar- rather than graph bar. If David is graphing means and we assume his variable is -x- and his category variable is -id-, he might try something like the following, . egen xm = mean(x), by(id) . sort id . twoway bar xm id if id != id[_n-1] , xlabel(1(5)46) or, even more simply . collapse (mean) x, by(id) . tw bar xm, xlabel(1(5)46) In the first case, we leave David's data intact, but must use an if condition to identify only one observation per group to be graphed. Note, that we can use -xlabel()- to control which bars are labeled. If David likes his bars to touch the X-axis, as they do in -graph bar-, he can add the option -plotregion(margin(b 0))-. He can also use -barwidth(#)- to control the width of the bars to taste. -- Vince vwiggins@stata.com * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**st: RE: RE: clogit or logistic for matched pairs** - Next by Date:
**Re: st: RE: clogit or logistic for matched pairs** - Previous by thread:
**st: RE: RE: clogit or logistic for matched pairs** - Next by thread:
**st: Outreg addstat limits!** - Index(es):

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