我用Matplotlib制作了一个图表,想要改变旋转的y轴标签的对齐方式。在这个代码示例中,“This is an example plot”文本应该向左对齐。将原始答案翻译成“最初的回答”。
import matplotlib.pyplot as plt
figure, axes = plt.subplots()
axes.plot([0, 1], [0, 1])
axes.set_ylabel('This is an\nexample plot', rotation=0)
axes.yaxis.set_label_coords(0.1, 0.9)
plt.show()