Open nick-youngblut opened 1 month ago
The text is rotated around the point at which it is aligned. By default that is the baseline/center. You need to change the alignment (va
& ha
), and also the rotation_mode
which affects the order of rotation and alignment.
theme(
axis_text_x=element_text(angle=45, va="top", ha="right", rotation_mode="anchor")
)
Thanks @has2k1 for the info! I didn't know that plotnine differed from the ggplot2 API in this regard. I'll keep that in mind.
Reopened so that it is documented.
reprex:
The resulting x-axis labels are not correctly positioned:
Using
pn.element_text(angle=45, hjust=1)
helps, but then the labels are too far to the left of each x-axis tick.Another example from my own data:
The most relevant sections of my very long conda env: