Data

Matplotlib 3.0 is here with new cyclic colormaps, and convenience methods

2 min read

Matplotlib team announced Matplotlib version 3.0, on Tuesday. Matplotlib 3.0 comes with new features such as two new cyclic colormaps, AnchoredDirectionArrows feature, and other updates and improvements.

Matplotlib is a plotting library for the Python programming language as well as for its numerical mathematics extension, NumPy. It offers an object-oriented API for embedding plots into applications using general-purpose GUI toolkits such as Tkinter, wxPython, Qt, or GTK+.

Let’s have a look at what’s new in this latest release.

Cyclic Colormaps

Two new colormaps namely ‘twilight’ and ‘twilight_shifted’ have been added to this new release. These two colormaps start and end on the same color. They have two symmetric halves with equal lightness, but diverging color.

AnchoredDirectionArrows added to mpl_toolkits

A new mpl_toolkit class AnchoredDirectionArrows, has been added in this release.

AnchoredDirectionArrows draws a pair of orthogonal arrows which helps indicate directions on a 2D plot.

Several optional parameters can alter the layout of these arrows. For instance, the arrow pairs can be rotated and their color can be changed. The labels and the arrows have the same color by default, but the class may also pass arguments for customizing arrow and text layout. Other than that, the location, length, and width of both the arrows can also be adjusted.

Improved default backend selection

The default backend needs no longer be set as part of the build process. Instead, builtin backends are tried in sequence at run time, until one of the imports.

Also, Headless Linux servers cannot select a GUI backend.

Scale axis by a fixed order of magnitude

With Matplotlib 3.0, you can scale an axis by a fixed order of magnitude by setting the scilimits argument of Axes.ticklabel_format to the same (non-zero) lower and upper limits. With this setting, the order of magnitude gets adjusted depending on the axis values, rather than remaining fixed.

minorticks_on()/off() methods added for colorbar

A new method colorbar.Colobar.minorticks_on() has been added in this new release that can correctly display the minor ticks on a colorbar. This method doesn’t allow the minor ticks to extend into the regions beyond vmin and vmax. A complementary method named colorbar.Colobar.minorticks_off() has also been added for removing the minor ticks on the colorbar.

New convenience methods for GridSpec

New convenience methods namely gridspec.GridSpec and gridspec.GridSpecFromSubplotSpec have been added in Matplotlib 3.0.

Other Changes

  • Colorbar ticks are now automatic.
  • Legend has a title_fontsize kwarg (and rcParam) now.
  • Multipage PDF support has been added for pgf backend.
  • Pie charts are now circular by default in Matplotlib 3.0
  • :math: directive has been renamed to :mathmpl:

For more information, be sure to check out the official Matplotlib release notes.

Read Next

Creating 2D and 3D plots using Matplotlib

How to Customize lines and markers in Matplotlib 2.0

Tinkering with ticks in Matplotlib 2.0

Natasha Mathur

Tech writer at the Packt Hub. Dreamer, book nerd, lover of scented candles, karaoke, and Gilmore Girls.

Share
Published by
Natasha Mathur

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