Question: How to decrease number of colorbar ticks from being overloaded?

Part of my python file reads

Plot X,Y,Z

fig, ax = plt.subplots()
ax.set_title(‘Day: 175 Hour: 24’);
cset1 = ax.contour(X, Y, Z, levels=100)
norm= mpl.colors.Normalize(vmin=cset1.cvalues.min(), vmax=cset1.cvalues.max())
sm =, cmap = cset1.cmap)
fig.colorbar(sm, ticks=cset1.levels, label=‘signal fft - log(mag)’)
ax.set_ylabel(‘Frequency hz’)
fig.savefig(‘test.png’, dpi=300)

But the colorbar tics is overloaded, as is obvious.

How can the code be fixed so the tics are easy to read, say intervals of 1 or 2 ?

I think your ticks setting in the call to colorbar is the problem. You should either remove that or set it to a sequence of numbers where you want the ticks.