Object-oriented way of using matplotlib – 5. Customizing Plots, Ticks

This entry is part 6 of 8 in the series OO matplotlib

 

 

 

 

I would like to post a series of articles about object-oriented way of using matplotlib. That explains why we should use that way and how to code like that. The main references are come from the official matplotlib website, “matplotlib.org” and  the book, 『Python Data Science Handbook: Essential Tools for Working with Data, Jake VanderPlas, O’REILLY, 2017』.

In the previous posts, we’ve tasted some differences between MATLAB styles and OO styles. We could learn how to add subplots in different ways. In this post, you can learn how to customize the various stuffs of a plot such as legend, tick and colorbar.

5. Customizing Plots

b. Customizing Ticks

Ticks are part of axis ( different from ‘axes’ ). You can adjust the ticks by Locator and Formatter objects. A plot has two axes (plural of axis), X and Y. So, Each axes (subplot) has xaxis object and yaxis object. You can assign major tick by set_major_locator(), while assigning minor tick by set_minor_locator().

Here is some example.
The full source code is here. [Link]

 

 

Series Navigation<< Object-oriented way of using matplotlib – 5. Customizing Plots, LegendObject-oriented way of using matplotlib – 5. Customizing Plots, Colorbar >>

Leave a Comment