Reputation: 11039
I have a plot
plt.xlim(xmin=0, xmax=max_value)
plt.plot(x,y)
where all values in x
are between 0
and max_value
.
It's important for me to have both start value 0
and end value max_value
on the x-axis in the plot.
If max_value = 88
, the plot will show labels 0, 10, 20, 30, 40, 50, 60, 70, and 80 but not 88. How can I make sure the plots shows the end value?
Upvotes: 0
Views: 2280
Reputation: 254
This use default labels and add max_value
:
plt.xticks(list(plt.xticks()[0]) + [max_value])
Upvotes: 2
Reputation: 426
Consider use plt.xticks
method:
x = range(0,100)
y = x
max_value = 88
plt.xlim(xmin=0, xmax=max_value)
plt.plot(x,y)
plt.xticks([0, 10, max_value/2, max_value])
plt.show()
Upvotes: 1