Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the text of clabel in Matplotlib

I would like to specify the text of my contour label (instead of the value of the contour I want to put a text) I've tried:

CS = contour(X, Y, Z, [0.5], linewidths=1, colors='k')
plt.clabel(CS, fontsize=10, inline=1, text=r'$\alpha=0$')

but it doesn't work. Any idea?

like image 903
Mermoz Avatar asked Nov 17 '10 11:11

Mermoz


People also ask

How do you label contour in Python?

Click the first button near a contour to add a label, click the second button (or potentially both mouse buttons at once) to finish adding labels. The third button can be used to remove the last label added, but only if labels are not inline.


1 Answers

Try this:

plt.clabel(CS, fontsize=10, inline=1, fmt=r'$\alpha=0$')
like image 179
miro Avatar answered Sep 21 '22 08:09

miro