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   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   Re: st: RE: Different graph height with graph, by()
Date   Wed, 15 Sep 2010 15:29:55 -0400

Thank you, Scott, this looks very promising. One problem is that there
are large areas between the combined graphs. This is most apparent
when a ysize() option is added to the combined graph, as shown below.
I experimented with graphregion(), plotregion() and imargin() without
success. I also found no information in the documentation for -graph
combine- on how to remove these empty areas.

Friedrich


sysuse auto, clear

local var rep78
levelsof `var',local(levels)

foreach l of local levels {
  qui sum mpg if `var' == `l'
  local a`l' = ceil(r(mean))
  disp `a`l''
  local suma = `suma' + `a`l''
}

foreach l of local levels {
  local grsize`l' = (`a`l''/`suma')*100
  disp `grsize`l''
}

foreach l of local levels {
  graph bar mpg if `var' == `l', ///
    name(gr`l', replace) fysize(`grsize`l'')
  local name "`name' gr`l'"
}

graph combine `name', cols(1) ysize(10)

graph drop `name'


On Wed, Sep 15, 2010 at 11:19 AM, Scott Merryman
<[email protected]> wrote:
> I am not sure if the absolute distance is the same, but here is one attempt:
>
> local var rep
> levelsof `var',local(levels)
>
> foreach l of local levels {
>        qui sum mpg if `var' == `l'
>        local a`l' = ceil(r(mean))
>        disp `a`l''
>        local suma = `suma' +  `a`l''
>        }
>
> foreach l of local levels {
>        local grsize`l' = (`a`l''/`suma')*100
>        disp `grsize`l''
>        }
>
> foreach l of local levels {
>        graph bar mpg if `var' == `l', ///
>           name(gr`l', replace) fysize(`grsize`l'')
>        local name "`name' gr`l'"
> }
>
> graph combine `name' , cols(1)
>
> graph drop `name'
>
>
> Scott
>
> On Wed, Sep 15, 2010 at 9:16 AM, Friedrich Huebler <[email protected]> wrote:
>> 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

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