Reputation: 3272
Let's say I have this code :
nbrs = np.array([0, 13, 13, 7, -9, 0])
x_values = np.array([0, 50, 100, 150, 200, 250])
plt.plot(nbrs)
plt.xticks(my_xticks)
When I tried xticks
it doesn't work :
nbrs = np.array([0, 13, 13, 7, -9, 0])
x_values = np.array([0, 50, 100, 150, 200, 250])
plt.plot(nbrs)
plt.xticks(my_xticks)
Instead of [1, 2, 3, 4, 5]
I want to have [0, 50, 100, 150, 200, 250]
.
Upvotes: 1
Views: 2049
Reputation: 3866
You should pass your x-values to the plt.plot
function. No need to use plt.xticks
. Like this:
import numpy as np
import matplotlib.pyplot as plt
nbrs = np.array([0, 13, 13, 7, -9, 0])
x_values = np.array([0, 50, 100, 150, 200, 250])
plt.plot(x_values,nbrs)
Upvotes: 0