Customize xtikers

Dear all
I am trying build a plot where I have a line that represents the standard measure and the actual numbers.
as there are much more actual figures than the standard measure I am struggling to get it right below is the code I am using

import pylab as plt
x = [1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9]
y = [1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9]
z = [1.75, 1.99, 1.88, 1.2, 2.33, 2.36, 2.36, 2.55, 3.66, 4.55, 9.99]
labels = [‘Aaa’,‘Aa’, ‘A’, ‘Baa’, ‘Ba’, ‘B’, ‘Caa’, ‘Ca’, ‘C’ ]
plt.plot(x,y, ‘r’)
plt.scatter(x, z, marker = ‘o’ )
plt.xticks(x, labels, rotation=‘vertical’)
plt.show()

any help is more than welcome

1 Like

Try this:
plt.xticks(range(1, len(x) - 1), labels=labels, rotation=“vertical”)

You’re setting xticks using x values which contain duplicate entries.

1 Like