A new color cycle named 'petroff10' was added. This cycle was constructed using a
combination of algorithmically-enforced accessibility constraints, including
color-vision-deficiency modeling, and a machine-learning-based aesthetics model
developed from a crowdsourced color-preference survey. It aims to be both
generally pleasing aesthetically and colorblind accessible such that it could
serve as a default in the aim of universal design. For more details
see Petroff, M. A.: "Accessible Color Sequences for Data Visualization" and related SciPy talk. A demonstration
is included in the style sheets reference. To load this color cycle in place
of the default:
Three diverging colormaps have been added: "berlin", "managua", and "vanimo".
They are dark-mode diverging colormaps, with minimum lightness at the center,
and maximum at the extremes. These are taken from F. Crameri's Scientific
colour maps version 8.0.1 (DOI: https://doi.org/10.5281/zenodo.1243862).
contour and contourf previously accepted a single color
provided it was expressed as a string. This restriction has now been removed
and a single color in any format described in the Specifying colors tutorial
may be passed.
The parameters hatch, edgecolor, facecolor, linewidth and linestyle
of the hist method are now vectorized.
This means that you can pass in individual parameters for each histogram
when the input x has multiple datasets.
matplotlib.ticker.EngFormatter can computes offsets now
matplotlib.ticker.EngFormatter has gained the ability to show an offset text near the
axis. Using logic shared with matplotlib.ticker.ScalarFormatter, it is capable of
deciding whether the data qualifies having an offset and show it with an appropriate SI
quantity prefix, and with the supplied unit.
To enable this new behavior, simply pass useOffset=True when you
instantiate matplotlib.ticker.EngFormatter. See example
.
Fix padding of single colorbar for ImageGrid
ImageGrid with cbar_mode="single" no longer adds the axes_pad between the
axes and the colorbar for cbar_location "left" and "bottom". If desired, add additional spacing
using cbar_pad.
ax.table will accept a pandas DataFrame
The table method can now accept a Pandas DataFrame for the cellText argument.
Boxplots have a new parameter orientation: {"vertical", "horizontal"}
to change the orientation of the plot. This replaces the deprecated
vert: bool parameter.
Violinplots have a new parameter orientation: {"vertical", "horizontal"}
to change the orientation of the plot. This will replace the deprecated
vert: bool parameter.
matplotlib.colorizer.Colorizer as container for norm and cmap
matplotlib.colorizer.Colorizer encapsulates the data-to-color pipeline. It makes reuse of colormapping easier, e.g. across multiple images. Plotting methods that support norm and cmap keyword arguments now also accept a colorizer keyword argument.
In the following example the norm and cmap are changed on multiple plots simultaneously:
importmatplotlib.pyplotasplt
3D plotting improvements
Fill between 3D lines
The new method Axes3D.fill_between allows to fill the surface between two
3D lines with polygons.
N=50theta=np.linspace(0,2*np.pi,N)x1=np.cos(theta)y1=np.sin(theta)z1=0.1*np.sin(6*theta)x2=0.6*np.cos(theta)y2=0.6*np.sin(theta)z2=2# Note that scalar values work in addition to length N arraysfig=plt.figure()ax=fig.add_subplot(projection='3d')ax.fill_between(x1,y1,z1,x2,y2,z2,alpha=0.5,edgecolor='k')
Rotating three-dimensional plots with the mouse has been made more intuitive.
The plot now reacts the same way to mouse movement, independent of the
particular orientation at hand; and it is possible to control all 3 rotational
degrees of freedom (azimuth, elevation, and roll). By default,
it uses a variation on Ken Shoemake's ARCBALL [1].
The particular style of mouse rotation can be set via
rcParams["axes3d.mouserotationstyle"] (default: 'arcball').
See also Rotation with mouse.
To revert to the original mouse rotation style,
create a file matplotlibrc with contents:
axes3d.mouserotationstyle:azel
Data in 3D plots can now be dynamically clipped to the axes view limits
All 3D plotting functions now support the axlim_clip keyword argument, which
will clip the data to the axes view limits, hiding all data outside those
bounds. This clipping will be dynamically applied in real time while panning
and zooming.
Please note that if one vertex of a line segment or 3D patch is clipped, then
the entire segment or patch will be hidden. Not being able to show partial
lines or patches such that they are "smoothly" cut off at the boundaries of the
view box is a limitation of the current renderer.
Support for free-threaded Python does not mean that Matplotlib is wholly thread safe. We
expect that use of a Figure within a single thread will work, and though input data is
usually copied, modification of data objects used for a plot from another thread may
cause inconsistencies in cases where it is not. Use of any global state (such as the
pyplot module) is highly discouraged and unlikely to work consistently. Also note
that most GUI toolkits expect to run on the main thread, so interactive usage may be
limited or unsupported from other threads.
If you are interested in free-threaded Python, for example because you have a
multiprocessing-based workflow that you are interested in running with Python threads, we
encourage testing and experimentation. If you run into problems that you suspect are
because of Matplotlib, please open an issue, checking first if the bug also occurs in the
“regular” non-free-threaded CPython 3.13 build.
Other Improvements
svg.id rcParam
rcParams["svg.id"] (default: None) lets you insert an id attribute into the top-level <svg> tag.
Where the #svg1 indicator will now refer to the top level <svg> tag, and
will hence result in the inclusion of the entire file.
By default, no id tag is included.
Exception handling control
The exception raised when an invalid keyword parameter is passed now includes
that parameter name as the exception's name property. This provides more
control for exception handling:
Figures using the Agg renderer are now limited to 2**23 pixels in each
direction, instead of 2**16. Additionally, bugs that caused artists to not
render past 2**15 pixels horizontally have been fixed.
Note that if you are using a GUI backend, it may have its own smaller limits
(which may themselves depend on screen size.)
All plotting methods that use a data-to-color pipeline now create a colorizer object if
one is not provided. This can be reused by subsequent artists such that they will share
a single data-to-color pipeline: