Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set minor locator

I am a beginner to matplotlib and came across a question about minor_locators. I tried looking it up but couldn’t work out how to create them in my bar graph. Any help is greatly appreciated.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The easiest way to set minor_locators is to use the AutoMinorLocator(). It gives you the generally most appropriate minor ticks without any hassles of setting them manually.
Add all of this to the code of your regular graph and you should be good to go:

import matplotlib.pyplot as plt
from matplotlib.ticker import AutoMinorLocator

ax = plt.gca()
ax.yaxis.set_minor_locator(AutoMinorLocator())
ax.xaxis.set_minor_locator(AutoMinorLocator())

For more specific ticks, read up on the official documentation here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading