Last week, the team behind Matplotlib announced the release of Matplotlib 3.1. This release comes with the support for Python 3.6+, a helper method for scatter legends, secondary axis support, a concise date formatter, and more.
Previously, for obtaining a legend for a scatter plot, users had two options: plotting several scatters, each with an individual label or, creating proxy artists to show in the legend manually. In Matplotlib 3.1, the PathCollection class comes with the legend_elements() method to obtain the handles and labels for a scatter plot in an automated way.
Matplotlib’s automatic date formatter is quite verbose, and that is why this version brings ConciseDateFormatter, which helps to minimize the strings used in the tick labels as much as possible. ConciseDateFormatter is a candidate for becoming the default date tick formatter in Matplotlib’s future releases.
Source: Matplotlib
Matplotlib 3.1 introduces a way to add a secondary axis on a plot for cases like converting radians to degrees on the same plot. With the help of Axes.axes.secondary_xaxis and Axes.axes.secondary_yaxis, you will now be able to make child axes with only one axis visible.
Source: Matplotlib
Two new classes, FuncScale and FuncTransform are introduced to provide users arbitrary scale transformations without having to write a new subclass of ScaleBase. You can use these through the following code:
‘ax.set_yscale('function', functions=(forward, inverse))’
Previously, in order to interact correctly with MacOSX through the native GUI framework, users required a framework build of Python. In this version, the app type is updated to remove this dependency so that the MacOSX backend works with non-framework Python.
Similar to the key_press events, figure managers now support a ‘button_press’ event that allows binding actions to mouse buttons. One of the applications of this event is supporting forward/backward mouse buttons in figures created with Qt5 backend.
These are a select few updates and additions. To read the full list of updates in Matplotlib 3.1, check out the official announcement.
Matplotlib 3.0 is here with new cyclic colormaps, and convenience methods
Creating 2D and 3D plots using Matplotlib
How to Customize lines and markers in Matplotlib 2.0