1

I am plotting the accuracy and loss figures. I am getting the following plot that represents 3 places after 0 like 0.XXX I aim to present only one like 0.X

how can I fix this

acc = history.history['accuracy']
acc_val = history.history['val_accuracy']
epochs = range(len(acc))
plt.title('Training and Validation accuracy')
plt.xlabel('Epochs')
plt.ylabel('accuracy')
plt.legend()
plt.show()

accuracy figure

Reem
  • 79
  • 6

1 Answers1

1

Try the below:

import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter

acc = history.history['accuracy']

fig, ax = plt.subplots()
plt.plot([i for i in range(len(acc))], acc)
ax.yaxis.set_major_formatter(FormatStrFormatter('%.1f'))
plt.show()

But you may see multiple ticks with the same value. Alternatively or in addition you can use the below to limit the ticks to what you want to be shown:

ax.set_yticks([0.8, 0.9, 1.0])