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

From |
Laura Gibbons <gibbonsl@u.washington.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
RE: st: RE: graph plot region size control |

Date |
Wed, 7 Nov 2007 15:41:54 -0800 (PST) |

Nick, these are some great tricks that I was not aware of. Thank you!

In the second section, the over variable is rep78, not foreign. I changed the stack command to:

stack price foreign weight rep78, into(data foreign) clear

Now I get a problem I had before when I tried a less elegant approach. The groups are now "Domestic Foreign 2 3 4 5". Is there a way to fix that so that the value 1 is labeled "Foreign" in the first figure and "1" in the second? Also there must be a way to supress the not applicable values; I haven't investigated that yet.

Finally, I'd like the ylines only on the applicable section, 4000, 8000 for foreign and 2000 3000 for rep78. Am I dreaming?!

Many thanks,

Laura

On Wed, 7 Nov 2007, Nick Cox wrote:

If not -by()-, then -over()-: use http://www.stata-press.com/data/r10/auto, clear preserve // tuck labels away carefully local l1 : var label price local l2 : var label weight tempfile mylabel label save origin using `mylabel' stack price foreign weight foreign, into(data foreign) clear // bring back labels label def _stack 1 "`l1'" 2 "`l2'" label val _stack _stack do `mylabel' label val foreign origin // now... graph hbox data, over(foreign) over(_stack) yline(2000 3000 4000 8000) /// xsize(3.25) ysize(2.375) restore Also, consider . stripplot price weight, by(foreign) box And many variations on that. (-stripplot- is from SSC.) Come to think of it, anything wrong with . graph hbox price weight, over(foreign) ? Nick n.j.cox@durham.ac.uk -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Laura Gibbons Sent: 07 November 2007 22:48 To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: graph plot region size control Nick and Maartin rightfully took me to task for giving up without explaining my actual goal. I apologize and appreciate your continued interest. I am trying to make (a series of) graphs that are the same size, where the plot regions are also the same size. Because the lengths of the labels vary, the plot regions are adjusted by Stata and I have no way to control them directly. It's not wrong, but it makes quick comparisons more difficult. Below is the type of graph I need to make. The values for yline will vary between graphs. Note that in this public example, price and weight measure different things, so it would seem silly to try to compare them, but in my real graphs, the variables are on the same scale, and I set the x axis to be the same range in all graphs. --------- use http://www.stata-press.com/data/r10/auto graph hbox price, over(foreign) yline(4000 8000) xsize(3.25) ysize(2.375) graph export f1.wmf, replace graph hbox weight, over(rep78) yline(2000 3000) xsize(3.25) ysize(2.375) graph export f2.wmf, replace -------- Though the overall sizes are the same, the plot region in f2 is larger because the labels are shorter. Since I last emailed, I have figured out how to improve things with the relabel option (below). Probably if I used a fixed (monospace) font or added more spaces I could get pretty close. But if there is a way to do this with by() or twoway, I'd love to learn it. And I would like there to be an option to set the plot region size. --------- graph hbox weight, over(rep78, /// relabel(1 " 1" 2 " 2" 3 " 3" 4 " 4" 5 " 5")) /// yline(2000 3000) xsize(3.25) ysize(2.375) graph export f3.wmf, replace --------- Thanks for any advice you may have, and for keeping me honest! -Laura On Wed, 7 Nov 2007, Maarten buis wrote:--- Laura Gibbons <gibbonsl@u.washington.edu> wrote:Unfortunately my graphs are more complicated than the bar graphs in the original post, so by() isn't an alternative. But if I could control the size of the plot region, I'd be home. It looks like I need to settle for uneven plot region sizes or use a different graphing program, and neither option is appealing.I can tell from experience that a surprising lot can be done with -by()-, even in very very complicated graphs (though you may need to use some tricks). So my gues is that you can do this with -by()- and thus save you a lot of trouble. If you don't tell us in what way your graphs are so complicated I cannot give you more advise than this very vague encouragement to have another good look at the by option.* * 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/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Laura E. Gibbons, PhD General Internal Medicine, University of Washington Box 359780 Harborview Medical Center 325 Ninth Avenue, Seattle, WA 98104 phone: 206-744-1842 fax: 206-744-9917 Office address: 401 Broadway, Suite 5122 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * * 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/

**References**:**Re: st: RE: graph plot region size control***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**Re: st: RE: graph plot region size control***From:*Laura Gibbons <gibbonsl@u.washington.edu>

**RE: st: RE: graph plot region size control***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: RE: graph plot region size control** - Next by Date:
**st: zanthro and the new 2006 WHO growth reference** - Previous by thread:
**RE: st: RE: graph plot region size control** - Next by thread:
**RE: st: RE: graph plot region size control** - Index(es):

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