E. Sommer
E. Sommer

Reputation: 750

Horizontal axis labelling causes white space on y axis

This is my data:

input y1 y2 y3 x
-0.34834709 -0.02733159 -0.6137266 97
-0.3906476 -0.12309019 -0.68878702 98
-0.43213382 -0.23861568 -0.76169004 99
-0.47270931 -0.28437565 -0.76154058 100
-0.51234194 -0.36507922 -0.81745737 101
-0.55110669 -0.44603292 -0.78759176 102
-0.58892858 -0.56973828 -0.89383692 103
end

A plot using a standard theme, looks alright:

tw connect y1 y2 y3 x, legend(off) ytitle("This is the title of the y axis") scheme(s2mono)

However, if I use my custom scheme, I get a large space between y-axis and y-axis title:

tw connect y1 y2 y3 x, legend(off) ytitle("This is the title of the y axis") scheme(custom)

enter image description here

I have been using this scheme for years and I had never problems of this kind.

This line from my .scheme file causes the white space (commenting out removes it):

anglestyle vertical_tick horizontal 

This seems weird, as the tick labels are pretty short, i.e. the space created is not really needed.

How could I tweak the scheme to force the axis title to be closer to the axis while maintaining the horizontal labelling?

By the way, I'm unable to reproduce this behavior with some sysuse data, that's why I provided the actual data.

Upvotes: 0

Views: 227

Answers (1)

user8682794
user8682794

Reputation:

This problem has nothing to do with the specified scheme (custom or not). This is an output format problem. Using your toy example:

clear
input y1 y2 y3 x
-0.34834709 -0.02733159 -0.6137266 97
-0.3906476 -0.12309019 -0.68878702 98
-0.43213382 -0.23861568 -0.76169004 99
-0.47270931 -0.28437565 -0.76154058 100
-0.51234194 -0.36507922 -0.81745737 101
-0.55110669 -0.44603292 -0.78759176 102
-0.58892858 -0.56973828 -0.89383692 103
end

tw connect y1 y2 y3 x, legend(off) ytitle("This is the title of the y axis") ///
ylabel(, angle(horizontal))

enter image description here

If you specify the desired output format, the problem goes away:

tw connect y1 y2 y3 x, legend(off) ytitle("This is the title of the y axis") ///
ylabel(,angle(horizontal) format(%3.1f))

enter image description here

Upvotes: 1

Related Questions