API Changes for 3.2.0#
Reduced default value of
Changed the default value of
[-5, 6]) from -7, 7 to
-5, 6 for better readability.
matplotlib.colorbar.Colorbar uses un-normalized axes for all mappables#
all axes limits between 0 and 1 and had custom tickers to handle the
labelling of the colorbar ticks. After 3.0, colorbars constructed from
mappables that were not contours were constructed with axes that had
vmax of the mappable's norm, and the tickers
were made children of the normal axes tickers.
This version of Matplotlib extends that to mappables made by contours, and allows the axes to run between the lowest boundary in the contour and the highest.
Code that worked around the normalization between 0 and 1 will need to be modified.
MovieWriterRegistry now always checks the availability of the writer classes
before returning them. If one wishes, for example, to get the first available
writer, without performing the availability check on subsequent writers, it is
now possible to iterate over the registry, which will yield the names of the
Matplotlib used to recompute autoscaled limits after every plotting
bar(), etc.) call. It now only does so when actually
rendering the canvas, or when the user queries the Axes limits. This is a
major performance improvement for plots with a large number of artists.
In some cases, this can result in different limits being reported. If this is
an issue, consider triggering a draw with
Autoscaling has also changed for artists that are based on the
class. Previously, the method that calculates the automatic limits
Collection.get_datalim tried to take into account the size of objects
in the collection and make the limits large enough to not clip any of the
object, i.e., for
Axes.scatter it would make the limits large enough to not
clip any markers in the scatter. This is problematic when the object size is
specified in physical space, or figure-relative space, because the transform
from physical units to data limits requires knowing the data limits, and
becomes invalid when the new limits are applied. This is an inverse
problem that is theoretically solvable (if the object is physically smaller
than the axes), but the extra complexity was not deemed worth it, particularly
as the most common use case is for markers in scatter that are usually small
enough to be accommodated by the default data limit margins.
While the new behavior is algorithmically simpler, it is conditional on
properties of the
offsets != None, and
offset_transformis child of
transformis child of
Axes.transData: use the
path + offsetfor limits (i.e., for
transformis not a child of
Axes.transData: just use the offsets for the limits (i.e. for scatter)
otherwise return a null
While this seems complicated, the logic is simply to use the information from the object that are in data space for the limits, but not information that is in physical units.
log-scale bar() / hist() autolimits#
The autolimits computation in
hist when the axes
already uses log-scale has changed to match the computation when the axes is
switched to log-scale after the call to
bar(..., log=True) /
hist(..., log=True): if there are
at least two different bar heights, add the normal axes margins to them (in
log-scale); if there is only a single bar height, expand the axes limits by one
order of magnitude around it and then apply axes margins.
Axes labels spanning multiple rows/columns#
Axes.label_outer now correctly keep the x labels and tick labels visible
for Axes spanning multiple rows, as long as they cover the last row of the Axes
grid. (This is consistent with keeping the y labels and tick labels visible
for Axes spanning multiple columns as long as they cover the first column of
the Axes grid.)
Axes.is_last_col methods now correctly return
True for Axes spanning multiple rows, as long as they cover the last row or
column respectively. Again this is consistent with the behavior for axes
covering the first row or column.
Axes.colNum attributes are deprecated, as they only
refer to the first grid cell covered by the Axes. Instead, use the new
properties, which are
range objects indicating the whole span of rows and
columns covered by the subplot.
(Note that all methods and attributes mentioned here actually only exist on
Subplot subclass of
Axes, which is used for grid-positioned Axes but
not for Axes positioned directly in absolute coordinates.)
GridSpec class gained the
ncols properties as more
explicit synonyms for the parameters returned by
Locator.nonsingular (introduced in mpl 3.1),
AutoDateLocator.nonsingular now returns a range
v0, v1 with
v0 <= v1.
This behavior is consistent with the implementation of
nonsingular by the
Axes.get_data_ratio now takes the axes scale into account (linear, log,
logit, etc.) before computing the y-to-x ratio. This change allows fixed
aspects to be applied to any combination of x and y scales.
Artist sticky edges#
sticky_edges attribute of artists was a list of values such
that if an axis limit coincides with a sticky edge, it would not be expanded by
the axes margins (this is the mechanism that e.g. prevents margins from being
added around images).
sticky_edges now have an additional effect on margins application: even if
an axis limit did not coincide with a sticky edge, it cannot cross a sticky
edge through margin application -- instead, the margins will only expand the
axis limit until it bumps against the sticky edge.
This change improves the margins of axes displaying a
if the streamplot goes all the way to the edges of the vector field, then the axis limits are set to match exactly the vector field limits (whereas they would sometimes be off by a small floating point error previously).
if the streamplot does not reach the edges of the vector field (e.g., due to the use of
maxlength), then margins expansion will not cross the vector field limits anymore.
This change is also used internally to ensure that polar plots don't display negative r values unless the user really passes in a negative value.
gid in svg output#
Previously, if a figure, axis, legend or some other artists had a custom
gid set (e.g. via
.set_gid()), this would not be reflected in
the svg output. Instead a default gid, like
figure_1 would be shown.
This is now fixed, such that e.g.
shows up as
<g id="myfigure"> in the svg file. If you relied on the
gid having the default format, you now need to make sure not to set the
gid parameter of the artists.
Font weight guessing now first checks for the presence of the FT_STYLE_BOLD_FLAG before trying to match substrings in the font name. In particular, this means that Times New Roman Bold is now correctly detected as bold, not normal weight.
matplotlib.colors.is_color_like used to return True for all string
representations of floats. However, only those with values in 0-1 are valid
colors (representing grayscale values).
is_color_like now returns False
for string representations of floats outside 0-1.
Default image interpolation#
Images displayed in Matplotlib previously used nearest-neighbor interpolation, leading to aliasing effects for downscaling and non-integer upscaling.
New default for
'antialiased') is the new option "antialiased".
imshow(A, interpolation='antialiased') will apply a Hanning filter when
resampling the data in A for display (or saving to file) if the upsample
rate is less than a factor of three, and not an integer; downsampled data is
always smoothed at resampling.
To always get the anti-aliasing behavior, no matter what the up/down sample
'antialiased') to "hanning" (or one of the other filters
Note that the "hanning" filter was chosen because it has only a modest performance penalty. Anti-aliasing can be improved with other filters.
True, externally written images now use a single counter even if the
renderer.basename attribute is overwritten, rather than a counter per
This change will only affect you if you used
rcParams["svg.image_inline"] = True
(the default is False) and manually modified
Changed the default value of
[-5, 6]) from -7, 7 to -5, 6
for better readability.
They now correctly return a 4-tuple.
indicate_inset would previously raise an error if
the optional inset_ax was not supplied; it now completes successfully,
and returns None instead of the tuple of
The pgf backend's get_canvas_width_height now returns the canvas size in
display units rather than in inches, which it previously did.
The new behavior is the correct one given the uses of
in the rest of the codebase.
The pgf backend now includes images using
\includegraphics instead of
\pgfimage if the version of
graphicx is recent enough to support the
interpolate option (this is detected automatically).
The default value of the "obj_type" parameter to
been changed from "attribute" (a default that was never used internally) to the
The test suite no longer turns on the Python fault handler by default.
Set the standard
PYTHONFAULTHANDLER environment variable to do so.
Backends do not need to explicitly define the flag
This is only relevant for backend developers. Backends had to define the flag
supports_blit. This is not needed anymore because the blitting capability
is now automatically detected.
Various APIs that raised a
ValueError for incorrectly typed inputs now raise
many classes in the
matplotlib.transforms module and
package, and Axes methods that take a
mpl_toolkits.mplot3d is always registered by default now. It is no
longer necessary to import mplot3d to create 3d axes with
ax = fig.add_subplot(111, projection="3d")
SymLogNorm now has a base parameter#
SymLogNorm had no base keyword argument and the base was
base=np.e. This was inconsistent with the default behavior of
SymmetricalLogScale (which defaults to
base=10) and the use of the word
"decade" in the documentation.
In preparation for changing the default base to 10, calling
without the new base keyword argument emits a deprecation warning.
.pyplot.plotfile is deprecated in favor of separately loading and plotting
the data. Use pandas or NumPy to load data, and pandas or matplotlib to plot
the resulting data.
axes and axis#
Axis.minor.formatter to an object that is not a subclass of
Formatter (respectively) is deprecated. Note that these attributes should
usually be set using
which already raise an exception when an object of the wrong class is passed.
Passing more than one positional argument or unsupported keyword arguments to
axis() is deprecated (such arguments used to be
minor argument will become keyword-only#
Using the parameter
set_*ticks() as a
positional parameter is deprecated. It will become keyword-only in future
mpl_toolkits.axes_grid1.colorbar module and its colorbar implementation
are deprecated in favor of
matplotlib.colorbar, as the former is
essentially abandoned and the latter is a more featureful replacement with a
nearly compatible API (for example, the following additional keywords are
The main differences are:
Setting the ticks on the colorbar is done by calling
colorbar()is deprecated in favor of its synonym
ticks(which already existed previously, and is consistent with
The colorbar's long axis is accessed with
colorbar.yaxisdepending on the orientation, rather than
The default ticker is no longer
MaxNLocator(5), but a
Overdrawing multiple colorbars on top of one another in a single Axes (e.g. when using the
ImageGridelements) is not supported; if you previously relied on the second colorbar being drawn over the first, you can call
cax.cla()to clear the axes before drawing the second colorbar.
During the deprecation period, the
rcParam can be set to True to use
mpl_toolkits.axes_grid1 code with a deprecation warning (the default),
or to False to use
pad size of
None (the default) as a synonym for zero to
new_vertical methods of
axes_grid1.axes_divider.AxesDivider is deprecated. In a future release, the
default value of
None will mean "use
0.2)" (depending on the orientation). Explicitly pass
pad=0 to keep the old behavior.
mplot3d.axis3d.get_flip_min_max is deprecated.
axes3d.unit_bbox is deprecated (use
.w_zaxis are deprecated (use
cm.revcmap is deprecated. Use
Colormap.reversed to reverse a colormap.
cm.datad no longer contains entries for reversed colormaps in their
mpl_toolkits.axisartist.grid_finder.GridFinderBase is deprecated (its
only use is to be inherited by the
GridFinder class which just provides
more defaults in the constructor and directly sets the transforms, so
GridFinderBase's methods were just moved to
axisartist.axis_artist.BezierPath is deprecated (use
to draw arbitrary Paths).
AxisArtist.line is now a
patches.PathPatch instance instead of a
Returning a factor equal to None from axisartist Locators (which are not the same as "standard" tick Locators), or passing a factor equal to None to axisartist Formatters (which are not the same as "standard" tick Formatters) is deprecated. Pass a factor equal to 1 instead.
mpl_toolkits.axisartist.axis_artist.AttributeCopier class, the
constructor and the
set_ref_artist method, and the default_value
get_attribute_from_ref_artist, are deprecated.
Deprecation of the constructor means that classes inheriting from
AttributeCopier should no longer call its constructor.
Locator.autoscale method is deprecated (pass the axis limits to
The following methods and attributes of the
MovieWriterRegistry class are
The "smart_bounds" functionality is deprecated. This includes
whis parameter of
"range" to mean "the whole data range" is deprecated; set it to (0, 100) (which
gets interpreted as percentiles) to achieve the same effect.
Passing scalars to parameter where in
fill_betweenx() is deprecated. While the documentation already states that
where must be of the same size as x (or y), scalars were accepted and
broadcasted to the size of x. Non-matching sizes will raise a
in the future.
Passing the verts parameter to
axes.Axes.scatter is deprecated; use the
marker parameter instead.
rcsetup.validate_animation_writer_path function is deprecated.
'png') to "auto" is deprecated; use its synonym "png" instead.
'force_autohint') to True or False is deprecated; use their synonyms
"auto" or "none" instead.
rcsetup.update_savefig_format is deprecated.
rcsetup.validate_path_exists is deprecated (use
os.path.exists to check
whether a path exists).
rcsetup.ValidateInterval is deprecated.
dates.mx2num is deprecated.
NavigationToolbar2Tk.set_active is deprecated, as it has no (observable)
NavigationToolbar2Wx.statbar are deprecated.
The status bar can be retrieved by calling standard wx methods
backend_wx.ConfigureSubplotsWx.get_canvas are deprecated.
RendererPgf.latexManager is deprecated.
FigureCanvasBase.draw_cursor (which has never done anything and has never
been overridden in any backend) is deprecated.
FigureCanvasMac.invalidate is deprecated in favor of its synonym,
dryrun parameter to the various
quiver.QuiverKey.quiverkey_doc is deprecated; use
mlab.stride_repeat are deprecated.
font_manager.createFontList is deprecated.
is now available to register a font at a given path.
matplotlib.ft2font.FT2Image are deprecated. Convert the
to a NumPy array with
np.asarray before processing it.
matplotlib.colors.makeMappingArray is not considered part of
the public API any longer. Thus, it's deprecated.
Using a string of single-character colors as a color sequence (e.g. "rgb") is deprecated. Use an explicit list instead.
matplotlib.testing.disable_internet module is deprecated. Use (for
example) pytest-remotedata instead.
matplotlib.testing for nose-based tests is deprecated (a
deprecation is emitted if using e.g. the decorators from that module while
both 1) matplotlib's conftests have not been called and 2) nose is in
testing.is_called_from_pytest is deprecated.
During the deprecation period, to force the generation of nose base tests, import nose first.
The switch_backend_warn parameter to
matplotlib.test has no effect and is
testing.jpl_units.UnitDbl.UnitDbl.checkUnits is deprecated.
DivergingNorm renamed to
DivergingNorm was a misleading name; although the norm was
developed with the idea that it would likely be used with diverging
colormaps, the word 'diverging' does not describe or evoke the norm's
mapping function. Since that function is monotonic, continuous, and
piece-wise linear with two segments, the norm has been renamed to
matplotlib.get_home is deprecated (use e.g.
matplotlib.compare_versions is deprecated (use comparison of
matplotlib.checkdep_ps_distiller is deprecated.
matplotlib.figure.AxesStack is considered private API and will be removed
from the public API in future versions.
BboxBase.is_unit is deprecated (check the Bbox extents if needed).
Affine2DBase.matrix_from_values(...) is deprecated. Use (for example)
get_data_path instead. (The rcParam is deprecated because it cannot be
meaningfully set by an end user.) The rcParam had no effect from 3.2.0, but
was deprecated only in 3.2.1. In 3.2.1+ if
'datapath' is set in a
matplotlibrc file it will be respected, but this behavior will be removed in 3.3.
matplotlib.testing.determinism module, which exposes no public API, has
The following API elements have been removed:
testing.decorators.skip_if_command_unavailable, support for nose-based tests
the normed keyword argument to
hist(use density instead)
(..., 3)when specifying a marker to specify a path or a circle, respectively (instead, use
The following members of
matplotlib.backends.backend_pdf.PdfFile were removed:
required_interactive_framework attribute of backend modules introduced
in Matplotlib 3.0 has been moved to the
FigureCanvas class, in order to
let it be inherited by third-party canvas subclasses and to make it easier to
know what interactive framework is required by a canvas class.
backend_qt4.FigureCanvasQT5, which is an alias for
backend_qt5.FigureCanvasQT (but only exists under that name in
backend_qt4), has been removed.
Previously, when building the
matplotlib._png extension, the build
script would add "png" and "z" to the extensions
.libraries attribute (if
pkg-config information is not available, which is in particular the case on
In particular, this implies that the Windows build would look up files named
z.lib; but neither libpng upstream nor zlib upstream
provides these files by default. (On Linux, this would look up
libz.so, which are indeed standard names.)
Instead, on Windows, we now look up
are the upstream names for the shared libraries (as of libpng 1.6.x).
For a statically-linked build, the upstream names are
zlibstatic.lib; one still needs to manually rename them if such a build
Previously, it was possible to package Windows DLLs into the Matplotlib
wheel (or sdist) by copying them into the source tree and setting the
package_data.dlls entry in
DLLs copied in the source tree are now always packaged; the
package_data.dlls entry has no effect anymore. If you do not want to
include the DLLs, don't copy them into the source tree.