1

How can I decrease the y tick with matplotlib?

Here is my code for create the plot:

plt.plot(loss)
plt.locator_params(nbins=10)
plt.title('andamento loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.show()
plt.savefig('andamento_loss.png')

but I get this error:

UserWarning: 'set_params()' not defined for locator of type <class 'matplotlib.category.StrCategoryLocator'>
  str(type(self)))

How can I solve this problem?

Davide
  • 185
  • 3
  • 22
  • 1
    Check this - https://stackoverflow.com/questions/40188264/controlling-the-number-of-x-ticks-in-pyplot – Tom Ron Apr 29 '19 at 17:13
  • Is it an error or just a warning? I could not reproduce the problem with your code, it works for me. I am using version 3.0.3 of matplotlib. – M. Zidan Apr 29 '19 at 17:34
  • @M.Zidan The reason it works for you is that you do not use a categorical dtype for the dataframe index. In general, the question does not show a [mcve], so I would simply close it as duplicate of the existing solution on that matter – ImportanceOfBeingErnest Apr 29 '19 at 17:38

0 Answers0