Stata tip: Rotating y labels and y title and adjusting axis title position

 •  Filed under Own charts, EU, Stata - tips and tricks

We have the following time series:

twoway (line ppp year if CEE==0, sort lwidth(*2) lcolor(midgreen)), ///  
graphregion(color(white)) ///  
xsize(10) ysize(7) ///  
title("Per capita income in old EU countries") ///  
ytitle("Per capita GDP in PPP") ///  
xtitle("")  

It will look better if we change the angle of the y-axis lalel by adding orientation(horizontal):



One would expect that to rotate the numbers on the vertical axis, something like ylabel(,orientation(horizontal)) would do the trick, but it won't work:

option orientation() not allowed

Instead, use ylabel(,angle(0)) to rotate the numbers:

Changing the position of the description of the y-variable: To push the title of the y-axis up, you do not even try ytitle("xy",position(10)). The option position works for legends, but it won't work here. You need to add placement(nw) option to the ytitle line.

(It also looks like justification(top) would not work either.)

If you want to customize the spacing between number of the y-axis, use ylabel(min(spacing)max,angle(45)).

The complete code is:

twoway (line ppp year if CEE==0, sort lwidth(*2) lcolor(midgreen)), ///  
graphregion(color(white)) ///  
xsize(10) ysize(7) ///  
title("Per capita income in old EU countries") ///  
ytitle("Per capita" "GDP" "in PPP",orientation(horizontal) placement(nw)) ///  
ylabel(,angle(0)) ///  
xtitle("")