Python scatter plot, axis scale

I'm doing a scatter plot for the vector y that contains 125 entries this way:

x = np.arange(1,126)

plt.scatter(x,y)

The case is I don't want the x-axis to have a number for each point in the diagram, I want to group the points in sets of 5, that is the number 1 in the x-axis correspond to the first 5 points, number 2 correspond to the next 5 and so on... so x should be:

x = np.arrage(1,26)

But I don't know if that is going to work.

Please help. Thanks you very much.

Upvotes: 0

Views: 102

Answers (1)

kkcheng
kkcheng

Reputation: 422

Try this. Not sure if it is what you are after. But hopefully a start.

ticks = []; j = 1
for i in x:
    if i % 5 == 0:
        ticks.append(j)
        j += 1
    else:
        ticks.append('')
plt.xticks(x, ticks)

Upvotes: 1

Related Questions