Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Scaling problem with graphs


From   Andrea Bennett <mac.stata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Scaling problem with graphs
Date   Thu, 23 Aug 2012 15:54:02 +0200

Oh dear, you are so right Thanks a lot for the hint!


On Aug 23, 2012, at 14:55 , Nick Cox <njcoxstata@gmail.com> wrote:

> From your bottom line it seems that these problems arise only because
> you think that
> 
> graph bar Score, over(abil) over(treatment)
> 
> can't be tweaked to produce different colours. However, that is not
> correct. The option -asyvars- has precisely this purpose.
> 
> Consider the results of
> 
> sysuse auto
> graph bar mpg, over(foreign) over(rep78)
> graph bar mpg, over(foreign) over(rep78) asyvars
> graph bar mpg, over(foreign) over(rep78) asyvars nofill
> 
> You can naturally add further options to change the colours, etc.
> 
> Nick
> 
> 
> On Thu, Aug 23, 2012 at 12:12 PM, Andrea Bennett <mac.stata@gmail.com> wrote:
>> Hi everyone,
>> 
>> I have the following issue with Stata graphs. Combining the below graphs results in the bars of the first graph to be slightly narrower that bars in the graphs 2 and 3. I think the issue is related to me dropping the y-scale from the second graph. Is there a way to make them exactly the same size, e.g. by dealing with the margins?
>> 
>> label define abil 0 "Low ability" 1 "High ability"
>> label values abil abil
>> 
>> global format "ytitle("Percent", size(large)) ylabel(0(20)100,  labsize(medium)) blabel(bar, format(%3.1f) size(medium)) ysc(r(0 100)) bar(1, color(gs12) lcolor(white) lwidth(thick)) bar(2, color(gs9) lcolor(white) lwidth(thick))"
>> 
>> graph bar Score if treatment==1, bargap(0) legend(span rows(1)) over(abil, axis(off)) $format asyvars b1title("Control", size(large) margin(large)) graphregion(margin(2 0 6 4)) saving(abil1, replace)
>> graph bar Score if treatment==2, bargap(0) yscale(off) over(abil, axis(off)) $format asyvars b1title("Treatment A", size(large) margin(large)) graphregion(margin(0 0 6 4)) legend(off) saving(abil2, replace)
>> graph bar Score if treatment==3, bargap(0) yscale(off) over(abil, axis(off)) $format asyvars b1title("Treatment B", size(large) margin(large)) graphregion(margin(0 0 6 4)) legend(off) saving(abil3, replace)
>> 
>> grc1leg abil1.gph abil2.gph abil3.gph, position(6) ring(1) rows(1) altshrink iscale(*1.5) legendfrom(abil1.gph) saving(abilfull, replace)
>> 
>> 
>> 
>> Before you wonder why I chose this approach over the following: graph bar Score, over(abil) over(treatment). I was not able to set different colours for the "abil" bars.
> 
> *
> *   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index