Controlling tick labeling
Tick labels are coordinates in the figure space. Although it makes sense for a fair number of cases, it is not always adequate. For instance, let's imagine a bar chart that shows the median income of 10 countries. We would like to see the names of the countries under each bar, rather than the coordinates of the bars. For a time series, we would like to see dates rather than some abstract coordinate. matplotlib provides a comprehensive API precisely for this. In this recipe, we will see how to control tick labeling.
How to do it...
Using the standard matplotlib ticks API, setting ticks for a bar chart (or any other kind of graphics) is done as follows:
import numpy as np import matplotlib.ticker as ticker import matplotlib.pyplot ...
Get matplotlib Plotting Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.