Note

Go to the endto download the full example code.

Dollar ticks#

Use a format string to prepend dollar signs on y-axis labels.

importmatplotlib.pyplotaspltimportnumpyasnp# Fixing random state for reproducibilitynp.random.seed(19680801)fig,ax=plt.subplots()ax.plot(100*np.random.rand(20))# Use automatic StrMethodFormatterax.yaxis.set_major_formatter('${x:1.2f}')ax.yaxis.set_tick_params(which='major',labelcolor='green',labelleft=False,labelright=True)plt.show()
dollar ticks

Gallery generated by Sphinx-Gallery