In addition to my comments on OP, you can build a graph with natural numbers from 1 to n, where n is the number of unqiue abscissa values ββin your dataset. Then you can set x ticklabels for these unique values. The only problem I encountered while implementing this is handling duplicate abscissa values. To try to save this general, I came up with the following
from collections import Counter
At this point, we get print x_normalised give
[0, 1, 2, 2, 3, 4, 5, 5, 5, 6]
So, build y against x_normalised with
from matplotlib.figure import Figure fig=Figure() ax=fig.add_subplot(111) y = [6.0, 5.0, 4.0, 2.5, 3.0, 2.0, 1.0, 2.0, 2.5, 2.5] ax.plot(x_normalised, y, 'bo')
gives

Finally, we can change the label labels on the x-axis to reflect the actual values ββof our original x-data using set_xticklabels using
ax.set_xticklabels(nonRepetitive_x)
Change To get the final graph, similar to the desired output in OP, you can use
x1,x2,y1,y2 = ax.axis() x1 = min(x_normalised) - 1 x2 = max(x_normalised) + 1 ax.axis((x1,x2,(y1-1),(y2+1)))