2

I have points x = [1000, 15000, 28000, 70000, 850000] y = [10000, 20000, 30000, 10000, 50000] and I get this graphic enter image description here

How can I set my own values on x axis?

Example : 1000, 15000, 28000, 70000, 850000

I Wanna get like this: enter image description here

3
  • Do you want them spaced equally that way then? Commented Nov 20, 2014 at 14:56
  • I want not linear change values on x axis Commented Nov 20, 2014 at 15:00
  • 1
    Ok, see my answer below, it should do what you want :) Commented Nov 20, 2014 at 15:00

1 Answer 1

4

Based on your graphic, you actually want the points to be spaced equally in x and then to set the equally spaced ticks as your custom x array.

The code below will plot them equally (it actually plots them at [0, 1, 2, 3, ...]). It then places ticks at the positions (0, 1, 2, 3,...) with the values given by x using the plt.xticks function.

import matplotlib.pyplot as plt

x = [1000,  15000, 28000, 70000, 850000]
y = [10000, 20000, 30000, 10000, 50000]

x_plot = range(len(y))

plt.plot(x_plot, y)

plt.xticks(x_plot, x)

plt.show()

Plot

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.