Reputation: 241
I have points
x = [1000, 15000, 28000, 70000, 850000]
y = [10000, 20000, 30000, 10000, 50000]
and I get this graphic
How can I set my own values on x axis?
Example : 1000, 15000, 28000, 70000, 850000
I Wanna get like this:
Upvotes: 2
Views: 6210
Reputation: 53668
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()
Upvotes: 4