I am using phyton 3.6 and want to limit the number of ticks to 5 in my plot. However, when using this code example the y-axis doesn't appear in ascending order. The x-axis, on the other hand, works fine. What am I doing wrong? An example plot is given here.
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocator, MaxNLocator,FuncFormatter, ScalarFormatter
plt.figure()
ax = plt.axes()
ax.plot(date, frequency,color='gray')
ax.xaxis.set_major_locator(MaxNLocator(5))
ax.yaxis.set_major_locator(MaxNLocator(5))
plt.xlabel('Timestamp')
plt.ylabel('Frequency (GHz)')
plt.show()