Hello,
I have a couple questions re labeling axes in a twoway scatter plot. How can I:
- Specify that x axis shows all values, when total number of values is unknown
xlabel(1/15, valuelabel labsize(vsmall) angle(45)) ///
- Specify that y axis shows intervals of 500, when max value is unknown
ylabel(0(10)50, angle(0)) ylabel(0(500)2000, angle(0) axis(2)) ///
The code that I am using is below. The intervals above are for `n'=1 but I want to be able to create graphs using the foreach loop that will label the categories properly for each of groups `n'=1 to `n'=6.
foreach n of numlist 1/6 {
preserve
keep if ha==`n' & fy==17 & m_robson==.
bysort ha fy m_robson (csrate): gen i_plot=_n
labmask i_plot, values(name_short)
codebook csrate_p numcase
twoway (scatter csrate_p i_plot) ///
(scatter numcase i_plot ///
, yaxis(2) mcolor(gs10)) ///
, ///
title("CD rate by hospital, `ha`n''", justification(left) position(11)) ///
subtitle("FY2017/18", justification(left) position(11)) ///
ytitle("CD rate (%)", angle(0)) ///
ytitle("Deliveries (n)", angle(0) axis(2)) ///
yscale(range(0(10)50) titlegap(*5)) ///
ylabel(0(10)50, angle(0)) ylabel(0(500)2000, angle(0) axis(2)) ///
xtitle(Hospital) ///
xlabel(1/15, valuelabel labsize(vsmall) angle(45)) ///
xscale(titlegap(*5)) ///
legend(position(11) col(3) region(lcolor(white)) symxsize(3) ///
label(1 "CD rate %") label(2 "Deliveries (n)")) ///
graphregion(fcolor(white) lcolor(black)) ///
name(csrate_`ha`n''_hosp, replace) ///
saving("$results/`ha`n''/Graphs/csrate_`ha`n''_hosp.gph", replace)
graph export "$results/`ha`n''/Graphs/csrate_`ha`n''_hosp.pdf", replace
restore
}
Thanks,
David Puddicombe
I have a couple questions re labeling axes in a twoway scatter plot. How can I:
- Specify that x axis shows all values, when total number of values is unknown
xlabel(1/15, valuelabel labsize(vsmall) angle(45)) ///
- Specify that y axis shows intervals of 500, when max value is unknown
ylabel(0(10)50, angle(0)) ylabel(0(500)2000, angle(0) axis(2)) ///
The code that I am using is below. The intervals above are for `n'=1 but I want to be able to create graphs using the foreach loop that will label the categories properly for each of groups `n'=1 to `n'=6.
foreach n of numlist 1/6 {
preserve
keep if ha==`n' & fy==17 & m_robson==.
bysort ha fy m_robson (csrate): gen i_plot=_n
labmask i_plot, values(name_short)
codebook csrate_p numcase
twoway (scatter csrate_p i_plot) ///
(scatter numcase i_plot ///
, yaxis(2) mcolor(gs10)) ///
, ///
title("CD rate by hospital, `ha`n''", justification(left) position(11)) ///
subtitle("FY2017/18", justification(left) position(11)) ///
ytitle("CD rate (%)", angle(0)) ///
ytitle("Deliveries (n)", angle(0) axis(2)) ///
yscale(range(0(10)50) titlegap(*5)) ///
ylabel(0(10)50, angle(0)) ylabel(0(500)2000, angle(0) axis(2)) ///
xtitle(Hospital) ///
xlabel(1/15, valuelabel labsize(vsmall) angle(45)) ///
xscale(titlegap(*5)) ///
legend(position(11) col(3) region(lcolor(white)) symxsize(3) ///
label(1 "CD rate %") label(2 "Deliveries (n)")) ///
graphregion(fcolor(white) lcolor(black)) ///
name(csrate_`ha`n''_hosp, replace) ///
saving("$results/`ha`n''/Graphs/csrate_`ha`n''_hosp.gph", replace)
graph export "$results/`ha`n''/Graphs/csrate_`ha`n''_hosp.pdf", replace
restore
}
Thanks,
David Puddicombe
Comment