Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python:How to change the granularity of axes in matplotlib plot?

I am wondering how to can change the number of bins in a line plot in matplotlin python pandas? like if my x axis range is [0,1000] and I want it be decided to 200 ticks. Can anybody help?

like image 826
UserYmY Avatar asked Feb 20 '26 03:02

UserYmY


1 Answers

Use the set_ticks function

from matplotlib import pyplot as plt

fig, ax = plt.subplots()
ax.set_xticks([0,200,400,800,1000])
like image 142
user3590169 Avatar answered Feb 21 '26 15:02

user3590169



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!