Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Matplotlib 3.1 releases with Python 3.6+ support, secondary axis support, and more

Save for later
  • 3 min read
  • 20 May 2019

article-image

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.

A helper method for scatter legends


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.

Formatting date ticks better with ConciseDateFormatter


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.

matplotlib-3-1-releases-with-python-3-6-support-secondary-axis-support-and-more-img-0

Source: Matplotlib


Secondary x/y axis support


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.

matplotlib-3-1-releases-with-python-3-6-support-secondary-axis-support-and-more-img-1

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at $19.99/month. Cancel anytime

Source: Matplotlib


FuncScale and FuncTransform for arbitrary axes scales


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))’

Working with Matplotlib on MacOSX no longer requires a Python framework build


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.

Support for forward/backward mouse buttons


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