Matplot lib : scalling of the axes on bar plot I am using following script to plot cluster populations using two lists contained x and y data
# calculate clusters using encore method
cluster = encore.cluster(u, select=&quot;all&quot;, superposition=False, method=encore.DBSCAN(eps=1))

# make list of population of each cluster;
cluster_sizes= [len(c) for c in cluster.clusters]
# make list of the cluster number;
cluster_numbers=[x+1 for x in range(0,len(cluster_sizes))]

# plot data
plt.bar(cluster_numbers, cluster_sizes)
plt.title('Cluster Populations')
plt.grid(True)
#plt.style.use('ggplot')
plt.savefig(f'clusters.png')
plt.close()

The problem that sometimes on the resulted bar plot the values are ranged by 0.5 along both X and Y (see the enclosed picture as the example). How I could plot only integers along the both axes? In my example graph the X should be scalled from 0 to 20 (avoiding 0.5 spacings) and the Y from 0 to 18 (thus avoiding these unused 0.5 spacings)
Use plt.xticks - https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.xticks.html.
One may to xticks np.arange(len(cluster.clusters)) as an argument
And for yticks it works in a same fashion -if you pass np.arange(int(max(cluster_sizes))), there will be integer ticks along the y-axis