Data

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

2 min read

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.

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.

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.

Read Next

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

 

Bhagyashree R

Share
Published by
Bhagyashree R

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago