How it works...

Here is the explanation of the code:

  • plt.ylabel('histogram', labelpad=20) plots ylable as 'histogram' and places it away by 20 units from the y axis spine.
  • This is required when yticklabels are long so that ylabel does not overlap with yticklabels.
  • However, this may lead to truncation when the figure is saved, as can be seen in the following images, again extracted from the respective output files generated by this code.

The preceding code generates the following output:

Please note that ylabel is missing in all the output ...

Get Matplotlib 3.0 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.