Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: RE: Different graph height with graph, by()


From   "Kieran McCaul" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: Different graph height with graph, by()
Date   Thu, 16 Sep 2010 07:31:21 +0800

...

yes, trial and error, but I got close on my first guess 40/60 and closer
on my second guess 45/55.  I think that the margin between each graph
will affect the proportion of space that you assign to each graph.
Setting the graphregion margin to zero would probably help.   With more
graphs in the stack, I think that the error due to the margin would be
less.

For doing the graphs by rep78, it depends on how you want the y-axis to
look.  If you wanted 5-units intervals on the y-axis, then the labels
would have to be defined separately for each of the graphs.  I'd then
use the highest tick values - 25 20 20 25 30 - for each of the graphs to
work out an approximate value for fysize().

So for the first graph, fsize() would be (25/(25+20+20+25+30))*100 =
20.8

I can get pretty close.

clear*
sysuse auto

graph bar mpg if rep78==1, ylabel(0(5)25) graphregion(margin(zero))
saving(g1,replace) fysize(20.8)
graph bar mpg if rep78==2, ylabel(0(5)20) graphregion(margin(zero))
saving(g2,replace) fysize(16.7)
graph bar mpg if rep78==3, ylabel(0(5)20) graphregion(margin(zero))
saving(g3,replace) fysize(16.7)
graph bar mpg if rep78==4, ylabel(0(5)25) graphregion(margin(zero))
saving(g4,replace) fysize(20.8)
graph bar mpg if rep78==5, ylabel(0(5)30) graphregion(margin(zero))
saving(g5,replace) fysize(25)

graph combine g1.gph g2.gph g3.gph g4.gph g5.gph, imargins(0 0 0 0)
cols(1)


forvalues 



-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Friedrich
Huebler
Sent: Wednesday, 15 September 2010 10:17 PM
To: [email protected]
Subject: Re: st: RE: Different graph height with graph, by()

Thank you, Kieran. Your commands produce the kind of graph I have in
mind. How did you obtain the values for the fysize() option? How would
one identify the right fysize() values for a graph with more
by-groups, as in the example below? Is this a matter of trial and
error?

graph bar mpg, by(rep78, col(1)) ysize(10)

Friedrich

On Tue, Sep 14, 2010 at 7:42 PM, Kieran McCaul
<[email protected]> wrote:
>
> Something like:
>
> sysuse auto
>
> graph bar mpg if foreign==0, saving(g1, replace) fysize(45)
> graph bar mpg if foreign==1, saving(g2, replace) fysize(55)
>
> graph combine g1.gph g2.gph, cols(1)
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Friedrich
> Huebler
> Sent: Wednesday, 15 September 2010 7:05 AM
> To: [email protected]
> Subject: st: Different graph height with graph, by()
>
> Is it possible to have graphs of different height with -graph, by()-?
> In the example below, two bar graphs are placed on top of each other.
> The upper bar has a height of 20, the lower bar a height of 25. The
> y-axis for the upper and lower graphs has the same range, from 0 to
> 25, and the graphs themselves have the same height.
>
> . sysuse auto
> . graph bar mpg, by(foreign, col(1)) name(a)
>
> Can the absolute height of the upper graph be reduced so that the
> scale only ranges from 0 to 20? In other words, can the area between
> 20 and 25 in the upper graph be cut while keeping the other components
> of the graph unchanged?
>
> The following command changes the scale but not the absolute height of
> the upper graph. In the upper graph, the absolute distance between 0
> and 20 on the y-axis is now the same as the distance between 0 and 25
> in the lower graph and the distance between 0 and 5 in the upper graph
> is greater than the distance between 0 and 5 in the lower graph.
>
> . graph bar mpg, by(foreign, col(1) yrescale) name(b)
>
> I am looking for a way to reduce the height of the upper graph while
> keeping the distance between the ticks of the y-axis identical in the
> upper and lower graph. Can this be done in Stata?
>
> Thanks,
>
> Friedrich
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index