Karl D Karl D - 1 year ago 84
Python Question

How to print Y axis label horizontally in a matplotlib / pylab chart?

I'm creating very simple charts with matplotlib / pylab Python module. The letter "y" that labels the Y axis is on its side. You would expect this if the label was longer, such as a word, so as not to extend the outside of the graph to the left too much. But for a one letter label, this doesn't make sense, the label should be upright. My searches have come up blank. How can I print the "y" horizontally?

Answer Source

It is very simple. After plotting the label, you can simply change the rotation:

from matplotlib import pyplot as plt
h = plt.ylabel('y')

Alternatively, you can pass the rotation as an argument, i.e

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download