[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: Sort order in graph box, over() by() |

Date |
Tue, 28 Aug 2007 13:36:56 +0100 |

I think Scott's main idea is right. To solve this, you need to create your own grouping variable upstream of the graph call. Here's another way to do it, however, that doesn't involve resorting to monkeying with extra observations ad hoc. sysuse auto, clear egen median = median(mpg), by(rep) egen axis = axis(median rep78), label(rep78) graph box mpg, over(axis) by(foreign, b1title(Repair record 1978)) Here you need to have installed -egenmore- from SSC to get -egen, axis()-. I have posted on this unofficial -egen- function before, so here are some related postings: www.stata.com/statalist/archive/2004-03/msg00454.html www.stata.com/statalist/archive/2007-07/msg00563.html www.stata.com/statalist/archive/2004-02/msg00485.html www.stata.com/statalist/archive/2007-08/msg00562.html If StataCorp would only add one option to -egen, group()- none of this would be necessary! I have bundled in the example above an extra trick. -graph box- won't let you use an -xtitle()- in this kind of graph because of -graph-'s dogma that the axis in question isn't an x-axis. A solution is to invoke -b1title()-. Those using graphics in Stata <=7 may remember that graph axis titles came in various flavours, being -l-, -r-, -b- or -t- according to whether they were on the left, right, bottom or top. It doesn't seem to be documented, but some of the associated options still persist in the new graphics, chiefly to allow Vince Wiggins a few extra handles for the very few occasions that he needs them. Nick n.j.cox@durham.ac.uk Scott Merryman > Like this? > > sysuse auto ,clear > egen median = median(mpg) ,by(rep) > graph box mpg, over(rep, sort(med)) by(fore) name(gr1,replace) > set obs 76 > replace fore = 1 in 75/76 > replace rep = 1 in 75 > replace rep = 2 in 76 > replace med = 18 if rep == 2 & fore == 1 > replace med = 20 if rep == 1 & fore == 1 > graph box mpg, over(rep, sort(med)) by(fore) name(gr2,replace) On 8/27/07, Stefan Kreisel <kreisel.stefan@web.de> wrote: > > I'll give it another (abbreviated, as suggested in the > Statalist FAQ...) try after receiving no response to "Forcing > sort order in graph box, over() by()" (see that thread for > any details). > > > > Is there a way to individually sort the order of boxes in a > given subgraph as produced by the by() option in e.g. -graph > box yvar, over(xvar, sort(1)) by(anothergroup)-? > > > > The problem is that missing categories on a given > subgrouping of by() get put on the far right most side of the > subgraph; I want them all in the same position in each subgraph. * * 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/

**Follow-Ups**:**RE: st: Sort order in graph box, over() by()***From:*"b. water" <barleywater@hotmail.com>

**References**:**Re: st: Sort order in graph box, over() by()***From:*"Scott Merryman" <scott.merryman@gmail.com>

- Prev by Date:
**st: ivreg vs. ivreg2 standard errors** - Next by Date:
**st: RE: How can I get square roots of elements in a matrix,in Stata8.2?** - Previous by thread:
**Re: st: Sort order in graph box, over() by()** - Next by thread:
**RE: st: Sort order in graph box, over() by()** - Index(es):

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