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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Expanding on the accepted answer, when we work with a particular axes object
ax
:Note that often the
labelpad
will need to be adjusted manually too — otherwise the "abc" will intrude onto the plot.From brief experiments I'm guessing that
labelpad
is the offset between the bounding box of the tick labels and the y-label's centre. (So, not quite the padding the name implies — it would have been more intuitive if this was the gap to the label's bounding box instead.)It is very simple. After plotting the label, you can simply change the rotation:
Alternatively, you can pass the rotation as an argument, i.e