Setting spacing between ticks in matplotlib 1

Setting spacing between ticks in matplotlib

plt.gca().xaxis.set_major_locator(plt.MultipleLocator(1))

Here is what the above code is Doing:
1. We’re creating a figure with a size of 8×6 inches.
2. We’re creating a subplot with 1 row, 1 column, and index 1.
3. We’re plotting the data.
4. We’re setting the x-axis label to “Time (days)”.
5. We’re setting the y-axis label to “Dollars”.
6. We’re setting the x-axis limits to be 0 to 30.
7. We’re setting the y-axis limits to be 0 to 17000.
8. We’re setting the x-axis ticks to be every 5 days.
9. We’re setting the y-axis ticks to be every 1000 dollars.

Similar Posts