Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: RE: AW: -graph combine- question


From   "G Livesey" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: AW: -graph combine- question
Date   Fri, 23 Oct 2009 19:52:06 +0100

Dear Statalisters,

Kieran says:
Is there "an easy way to ensure that the LENGTH of the x-axis is the same in
all FOUR graphs".


As  Kieran, Nick, and I find, it seems there is some fiddling to do to get
what one is aiming for. Some method of command to control events (if
possible) rather than fiddling around would be helpful, especially when
several graphs are combined. Here I show FOUR graphs as a 2row x 2col
combination, but have done 4row x 4col combinations and had to fiddle
extensively. 

Including Nick's clever suggestion is helpful with some settings, but not
necessarily with others.
With other backgrounds/schemes the approach may not be ok as color of the
ytitle  may be seen through the background, as in example that follows, and
presumably would not work at all when the graph is edited to be transparent
- say in PowerPoint:



sysuse auto, clear
gen mpgX2= 2* mpg
gen priceX1p5=1.5*price
gr twoway scatter mpg price, ytitle("Hello" "world 1")  xtitle("") name(one)
graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpgX2 priceX1p5, ytitle("", color("scheme background"))
xtitle("") name(two)  graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpg price, ytitle("Hello" "world 3") name(three)
graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpg price, ytitle("", color("scheme background"))
name(four)  graphregion(color(white)) ysize(2) xsize(2)
gr combine   one two  three four, row(2) ysize(2) xsize(2) ycommon xcommon
graphregion(color(white))


When the ytitles in the offending graphs are removed then the x-axis lengths
differ, as in the next example:


sysuse auto, clear
gen mpgX2= 2* mpg
gen priceX1p5=1.5*price
gr twoway scatter mpg price, ytitle("Hello" "world 1")  xtitle("") name(one)
graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpgX2 priceX1p5, ytitle("", color("scheme background"))
xtitle("") name(two)  graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpg price, ytitle("Hello" "world 3") name(three)
graphregion(color(white)) ysize(2) xsize(2)
gr twoway scatter mpg price, ytitle("", color("scheme background"))
name(four)  graphregion(color(white)) ysize(2) xsize(2)
gr combine   one two  three four, row(2) ysize(2) xsize(2) ycommon xcommon
graphregion(color(white))


I modifies the data so that it is not identical in each graph, which is more
usually the case and this difference in  data can affect the presentation.
Maybe this problem is one for the developers at some point?

Thans to all,

Geoff. L>


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Nick Winter
Sent: 23 October 2009 15:29
To: [email protected]
Subject: Re: st: RE: AW: -graph combine- question


Indeed, I have struggled with this as well.  The not-perfect solution I 
usually use is to force Stata to include the space that the titles 
*would* take up in each graph, so the x-axis ends up the same size in 
all of them.  This can be done by setting the color of the title to 
"scheme background":


. gr twoway scatter mpg price, ytitle("Hello" "world") name(one)

. gr twoway scatter mpg price, ytitle("Hello" "world", color("scheme 
background")) name(two)

. gr combine one two


And then fiddle with the -imargin- option to -graph combine- to get them 
closer together if desired.

-Nick


On 10/23/2009 4:59 AM, G Livesey wrote:
> Dear Statalisters,
> 
> Kieran's question is a good one. Martine's answer may solve Kieran's
> current problem, though only partially answers the question.
> 
> "ensure that the LENGTH of the x-axis is the same"
> 
> I have no easy solution  to do this and ask how to do this when the
> graphs to combine do not have
> 
> A) a common x-axis or
> B) perhaps (I did not try this) span different ranges of a common axis 
> or
> C) carry different axis-titles (e.g. some with and some without such
> titles), which can affect the proportion of space given to the graph and
> axis/margins and so length of the axis.
> 
> A more comprehensive solution than -common axis- would be welcome
> though I have not found one myself, and like Kieran have in the past 
> had to play about a lot to get what I want.
> 
> Does a solution exist? Can one be created?
> 
> With much appreciation and many thanks,
> 
> Geoff. Livesey
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Martin
> Weiss
> Sent: 23 October 2009 09:20
> To: [email protected]
> Subject: st: AW: -graph combine- question
> 
> 
> 
> <>
> 
> You are not looking for the -xcommon- option to -graph combine-, are
> you?
> 
> 
> *************
> clear*
> set obs 10000
>  
> 
> gen x1=  rnormal(10,100)
> gen x2=  rnormal(100,10)
> 
> gen num=_n
> 
> tw (line x1 num) in 1/5000,  /*
> */ name(gr1, replace) nodraw
> tw (line x2 num),  /*
> */ name(gr2, replace) nodraw
> 
> graph combine gr1 gr2, /*
> */ ycommon xcommon
> *************
> 
> 
> 
> HTH
> Martin
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Kieran
> McCaul
> Gesendet: Freitag, 23. Oktober 2009 04:33
> An: [email protected]
> Betreff: st: -graph combine- question
> 
> ....
> 
> Suppose I have four graphs that I combine to look like this:
> 
> http://i37.tinypic.com/314wkfb.jpg
> 
> My question is: is there an easy way to ensure that the length of the
> x-axis is the same in all four graphs when they are combined.
> 
> I can probably fiddle around with margin gaps until I get them right,
> but is there something a little easier than that?
> 
> Thanks.
> 
> 
> ______________________________________________
> Kieran McCaul MPH PhD
> WA Centre for Health & Ageing (M573)
> University of Western Australia
> Level 6, Ainslie House
> 48 Murray St
> Perth 6000
> Phone: (08) 9224-2701
> Fax: (08) 9224 8009
> email: [email protected] http://myprofile.cos.com/mccaul 
> http://www.researcherid.com/rid/B-8751-2008
> ______________________________________________
> If you live to be one hundred, you've got it made.
> Very few people die past that age - George Burns
> 
> 
> 
> *
> *   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/
> 
> 
> *
> *   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/
> 
> 
> *
> *   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/

-- 
--------------------------------------------------------------
Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
PO Box 400787, 100 Cabell Hall
Charlottesville, VA 22904

*
*   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/


*
*   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/



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