Putting newline in matplotlib label with TeX in Python?
- by user248237
How can I add a newline to a plot's label (e.g. xlabel or ylabel) in Matplotlib? For example,
plt.bar([1, 2], [4, 5])
plt.xlabel("My x label")
plt.ylabel(r"My long label with $\Sigma_{C}$ math \n continues here")
Ideally i'd like the y-labeled to be centered too. Is there a way to do this? It's important that the label have both tex (enclosed in '$') and the newline.
thanks.