Adjusting axes and ticks
In data visualization, it is often not enough to only display the trend in a relative sense. An axis scale is essential to facilitate value estimation for proper interpretation. Ticks are markers on an axis that denote the scale for this purpose. Depending on the nature of data and figure layout, we often need to adjust the scale and tick spacing to provide enough information without clutter. In this section, we are going to introduce the customization methods.
Customizing tick spacing with locators
There are two sets of ticks to mark coordinates on each axis: major and minor ticks. By default, Matplotlib tries to automatically optimize the tick spacing and format based on the data input. Wherever manual adjustment is needed, it can be done through setting these four locators: xmajorLocator
, xminorLocator
, ymajorLocator
, yminorLocator
via the function set_major_locator
, or set_minor_locator
on the respective axis. The following is a usage example, where ax
is an axes...