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: Twoway graph with different scaled y axes
From
Maria Ana Vitorino <[email protected]>
To
[email protected]
Subject
Re: st: Twoway graph with different scaled y axes
Date
Tue, 19 Mar 2013 20:08:16 -0500
Thanks for the advice and the help!
Best,
Ana
On Mar 19, 2013, at 6:04 PM, Nick Cox wrote:
> One small answer: Don't do that. The more I think about it, this graph
> is already too busy. Separate the rates and the cases and plot side by
> side. That's my advice.
>
> Nick
>
> On Tue, Mar 19, 2013 at 10:46 PM, Maria Ana Vitorino <[email protected]> wrote:
>> Thanks! This was very helpful.
>> One small question now...how do I edit the legend so that it looks like the one at
>>>> http://www.cancerresearchuk.org/cancer-info/cancerstats/incidence/age/#Cancer
>>
>> Thanks again,
>> Ana
>>
>>
>>
>>
>> On Mar 19, 2013, at 4:39 PM, Nick Cox wrote:
>>
>>> You should forget about -graph bar- and move to -twoway-.
>>>
>>> Here's an example:
>>>
>>> clear
>>>
>>> input age1 age2 str1 gender cases rate
>>> 15 20 F 10000 5.3
>>> 20 25 F 15000 8.3
>>> 25 30 F 12000 6.5
>>> 15 20 M 18000 9.3
>>> 20 25 M 12000 5.3
>>> 25 30 M 8000 2.5
>>> end
>>>
>>> gen rate2 = rate * 1000
>>> gen x = (age1 + age2) / 2 + cond(gender == "F", 1, -1)
>>>
>>> twoway bar cases x if gender == "F", barw(2) bcolor(pink*0.5) || ///
>>> bar cases x if gender == "M", barw(2) bcolor(blue*0.5) || ///
>>> connected rate2 x if gender == "F", mcolor(pink*0.5) lcolor(pink*0.5) || ///
>>> connected rate2 x if gender == "M", mcolor(blue*0.5) lcolor(blue*0.5) ///
>>> yaxis(1 2) yla(0 2000 "2" 4000 "4" 6000 "6" 8000 "8" 10000 "10", axis(1)) ///
>>> xtitle(age) xla(17.5 "15-20" 22.5 "20-25" 27.5 "25-30") legend(off) ///
>>> ytitle(rate, axis(1)) ytitle(cases, axis(2))
>>>
>>> NB: the boundaries 20, 25, etc. are ambiguous.
>>>
>>> Nick
>>>
>>>
>>> On Tue, Mar 19, 2013 at 9:24 PM, Maria Ana Vitorino <[email protected]> wrote:
>>>> Dear Statalist members,
>>>>
>>>> I'm trying to do 2 graphs on the same figure but am having trouble with twoway.
>>>>
>>>> Here is a sample of my data:
>>>>
>>>> agegroup gender cases rateper1000
>>>> 15-20 F 10000 5.3
>>>> 20-25 F 15000 8.3
>>>> 25-30 F 12000 6.5
>>>> 15-20 M 18000 9.3
>>>> 20-25 M 12000 5.3
>>>> 25-30 M 8000 2.5
>>>>
>>>> I would like to have both figures in the same plot:
>>>>
>>>> 1) graph bar cases, over(gender, label(labsize(small))) asyvars over(agegroup, label(labsize(vsmall))) ytitle("Number of Cases") b1title("Age")
>>>>
>>>> AND
>>>>
>>>> 2) a graph that has the variable rateper1000 on another axis and that shows (with dots) the rate per agegroup and age and connects those dots.
>>>>
>>>> The figure at http://www.cancerresearchuk.org/cancer-info/cancerstats/incidence/age/#Cancer
>>>> depicts well what I am trying to achieve.
>>> *
>>> * For searches and help try:
>>> * http://www.stata.com/help.cgi?search
>>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/