[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 |
st: RE: graph hbox Y, by(something noiyaxes) over(grp2) over(grp1) |

Date |
Mon, 20 Apr 2009 14:57:42 +0100 |

Scott posted excellent code but no commentary. Here is some commentary on Jacob's questions for those who would like it. 1. To clear a minor point out of the way first, using -more- rather than -pause- as a command immediately after a graph is a slightly cleaner and more direct way of ensuring that a slide show rather than a movie that flashes past. 2. An odd but prominently documented feature of -graph hbox- (and -graph hbar-) is that the response axis is still considered the y axis, even though it is now horizontal. Thus the help for -graph hbox- says "-graph hbox- draws horizontal box plots. In a horizontal box plot, the numerical axis is still called the y axis, and the categorical axis is still called the x axis, but y is presented horizontally, and x vertically." This accounts for part of Jacob's confusion. In essence, having the syntax this way round is intended as the lesser of two evils. That is, if you draw a box plot one way and decide it should be the other, it may well be that changing from -graph box- to -graph hbox-, or vice versa, is as much syntax as you need to change. 3. An odd and not very well documented feature of -graph *box- (and some some other kinds of graphs) is that one axis is considered categorical rather than numerical. This sometimes manifests itself negatively in that the axis no longer has all the properties of a "standard" axis. So, even if you realise that the response axis is always the y axis, standard x axis options don't necessarily apply to the other axis. The help for -graph box- does contain pointers to relevant classes of options. 4. It does seem that various options of -by()- do not bite with -graph hbox-. I can't explain why. 5. Scott showed how to suppress what you do not want using (the keyboard equivalent of) the Graph Editor. An open question is whether there is another way to do it via the command language. Nick n.j.cox@durham.ac.uk Scott Merryman clear all sysuse auto set scheme lean1 egen PriceCat=cut(price), at(3000 6000 16000) graph hbox turn, by(PriceCat, noiylabel noiyaxes rows(1)) over(headroom) over(foreign) name(gr1,replace) //use the graph editor or by command line: gr_edit plotregion1.supaxis[2].draw_view.setstyle, style(no) gr_edit plotregion1.grpaxis[2].draw_view.setstyle, style(no) Jacob Wegelin The artificial example below creates a "by" plot (two plots, in a row) with a superfluous row of labels for the levels of -foreign- and of -headroom- between the left and right graphs. I'd like to eliminate the second set of labels, that is, those for the plot on the right, and smash the two plots together with very little space between them. In particular, the labels "Domestic" and "Foreign" should appear only once on the entire "by" plot. The -noixaxes- and -noiyaxes- options seem ineffectual with -graph hbox-, as does -style(compact)- . Is there an simple or elegant solution? clear all sysuse auto set scheme lean1 pause on egen PriceCat=cut(price), at(3000 6000 16000) * All axes and labels are printed: graph hbox turn, by(PriceCat, noiylabel noiyaxes rows(1)) over(headroom) over(foreign) pause Enter q to continue, BREAK to halt. * The horizontal axis labels are not printed, which is the opposite of what I want: graph hbox turn, by(PriceCat, noixlabel noixaxes rows(1)) over(headroom) over(foreign) pause Enter q to continue, BREAK to halt. * Theoretically a workaround would consist in making two plots, the second one without axis labels for "headroom" and "foreign". * Then one could use -graph combine-. * But the following removes the information from the horizontal, i.e., the wrong, axis: graph hbox turn if PriceCat==3000, over(headroom) over(foreign) ylabel(, nolabels) pause Enter q to continue, BREAK to halt. * and the following generates an error. Apparently the vertical axis is not considered an axis at all in a boxplot: graph hbox turn if PriceCat==3000, over(headroom) over(foreign) xlabel(, nolabels) * * 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/

**References**:**st: graph hbox Y, by(something noiyaxes) over(grp2) over(grp1)***From:*Jacob Wegelin <jacob.wegelin@gmail.com>

- Prev by Date:
**st: announcing mark_changes** - Next by Date:
**st: egen, fill() [was:graph question]** - Previous by thread:
**Re: st: graph hbox Y, by(something noiyaxes) over(grp2) over(grp1)** - Next by thread:
**[no subject]** - Index(es):

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