In Matplotlib, pass minor=True when setting ticks:
minor=True
import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([0, 1, 2], [0, 100, 250]) values = [10, 50, 120, 200] # your given values ax.set_yticks(values, minor=True) # optional: style the minor ticks so they're visible ax.tick_params(axis='y', which='minor', length=3, color='gray') plt.show()
Key points:
ax.set_yticks(values, minor=True)
ax.set_yticks(major_values)
from matplotlib.ticker import MultipleLocator ax.yaxis.set_minor_locator(MultipleLocator(5)) # minor tick every 5 units
ax.set_yticklabels(labels, minor=True)
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.
Vibe can make mistakes. Check answers. Learn more