0

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.

1

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.