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

Reading Time:

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("") 

Economic recovery in Spain

According to European Commission's Winter 2016 Economic Forecast, Spain's gross domestic product grew 3.2% in 2015 and is expected to grow at a 2.8%...

Data analysis: Resource page

General visualization principles for social scientists An Economist's Guide to Visualizing Data by Jonathan A. Schwabish [Form and Function post] Using Graphs Instead of Tables in...