1

When I am plotting plt.scatter([0,1,2,3,4,5],[10001,10002,10003,10004,10005,10006]), I obtain this figure :

enter image description here

I think that as I plot small variations of large values, the values are not written directly on the Y-axis and are replaced by 1, 2, 3, 4, 5, 6 + 1e4.

Is there a way to force the direct writing of the y-axis values: 10001, 10002, 10003 ,... ?

I haven't found anything on the doc matplotlib.pyplot.scatter.

lauriane.g
  • 337
  • 1
  • 11

1 Answers1

1

Based on the answers here: How do I format axis number format to thousands with a comma in matplotlib?, I would recommend somthing like:

from pylab import *
plt.scatter([0,1,2,3,4,5],[10001,10002,10003,10004,10005,10006]);
gca().yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}'))
show();

You improve this!

msi_gerva
  • 2,021
  • 3
  • 22
  • 28
  • I changed : gca().yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:,.0f}')) in gca().yaxis.set_major_formatter(mpl.ticker.StrMethodFormatter('{x:.0f}')) to obtain the format I wanted (without comma). Thanks – lauriane.g Sep 29 '20 at 12:18