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]

st: RE: setting axis scale to maximum value of a variable


From   Nick Cox <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: setting axis scale to maximum value of a variable
Date   Mon, 11 Jun 2012 10:31:26 +0100

First question: -ylabel()- has a -format()- suboption which you can use to override the default (which Stata will pick up otherwise from the display format of your y axis variable). This is documented at -help axis label options-. 

Second question is more obscure to me. Perhaps studying the options and suboptions as above will indicate a solution. Or assign value labels to your y axis variable. 

Nick 
[email protected] 

Tim Evans

I have two questions, the first one is, how do I set the formatting of the y axis when graphing twoway so that I don't display any significant figures - i.e I want to show 150 and not 150.00 as I currently have.

The second question is, I am running a loop of graphs on rates that I have generated. However, the scale I set in the twoway line graph may not be appropriate for each version of the graph I generate. So for instance I have 3 age groups 0-49, 50-64 and 64-79, the maximum value for 'crude' is say 100 for 0-49, 300 for 50-64 and 400 for 64-79. Defaulting the y-axis to 400 (as I am currently doing) will make the 0-49 graph look odd as it wont be scaled appropriately. 

Is there a way that I can specify in the options that the y-axis is only scaled up to the nearest 10 of the maximum for each iteration of the loop?

My code is this:

levelsof age_grp, local(levels)
foreach l of local levels {
line crude yydx if surg==2 & age_grp==`l', lpattern("l") || line crude yydx if surg==1 & age_grp==`l',  lpattern("_")|| line crude yydx if surg==99 & age_grp==`l', lpattern(".._..") xaxis(1 2) ,  /*
*/ ylabel(0 (50) 400, gmax angle(horizontal)) /*
*/ xlabel(2001, axis(1)) xtitle("Year", size(small) axis(2)) xtitle("", axis(1)) plotregion(lstyle(none)) /*
*/ ytitle("Rate per 100,000 women", size(small)) title("`: label (age_grp) `l''", size(medsmall)) /*
*/ legend(label(3 "All breast cancer") /*
*/ label(2 "Mastectomy") label(1 "Breast surgery")) /*
*/ legend(region(lstyle(none)) rows(1) size(small) lcolor(none))
}


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