Friday 3 November 2023

How to add minor ticks to x and y axis?

We add minor ticks to the x and y axes using ax.minorticks_on()

minor_ticks.py

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(1, 10)
y = 10 * x + 123

plt.plot(x, y)

plt.minorticks_on()

# Show the plot
plt.show()

 

 

 

  

Previous                                                    Next                                                    Home

No comments:

Post a Comment