Switching backends via matplotlib.use is now allowed by default,
regardless of whether matplotlib.pyplot has been imported. If the user
tries to switch from an already-started interactive backend to a different
interactive backend, an ImportError will be raised.
Invalid points in PathCollections
PathCollections created with now keep track of invalid points.
Previously, points with nonfinite (infinite or nan) coordinates would not be
included in the offsets (as returned by ) of a
created by , and points with nonfinite values
(as specified by the kwarg) would not be included in the array (as returned
by )
The alpha-channel of RBGA images is now re-sampled independently of
RGB channels. While this is a bug fix, it does change the output and
may result in some down-stream image comparison tests to fail.
Autoscaling
On log-axes where a single value is plotted at a "full" decade (1, 10, 100,
etc.), the autoscaling now expands the axis symmetrically around that point,
instead of adding a decade only to the right.
Log-scaled axes
When the default LogLocator would generate no ticks for an axis (e.g., an
axis with limits from 0.31 to 0.39) or only a single tick, it now instead falls
back on the linear AutoLocator to pick reasonable tick positions.
Minor ticks that collide with major ticks are now hidden by default.
Previously, certain locator classes (LogLocator,
AutoMinorLocator) contained custom logic to avoid emitting
tick locations that collided with major ticks when they were used as
minor locators. This logic has now moved to the Axis class,
and is used regardless of the locator class. You can control this
behavior via the remove_overlapping_locs attribute on
Axis.
If you were relying on both the major and minor tick labels to appear
on the same tick, you may need to update your code. For example, the
following snippet
labeled days using major ticks, and hours and minutes using minor
ticks and added a newline to the major ticks labels to avoid them
crashing into the minor tick labels. Setting the
remove_overlapping_locs property (also accessible via
set_remove_overlapping_locs /
get_remove_overlapping_locs and setp) disables
removing overlapping tick locations.
The major tick labels could also be adjusted include hours and
minutes, as the minor ticks are gone, so the major_formatter
would be:
mdates.DateFormatter("%H:%M\n%a")
usetex support
Previously, if rcParams["text.usetex"] (default: False) was True, then constructing a TextPath on
a non-mathtext string with usetex=False would rely on the mathtext parser
(but not on usetex support!) to parse the string. The mathtext parser is not
invoked anymore, which may cause slight changes in glyph positioning.
get_window_extents
matplotlib.axes.Axes.get_window_extent used to return a bounding box
that was slightly larger than the axes, presumably to take into account
the ticks that may be on a spine. However, it was not scaling the tick sizes
according to the dpi of the canvas, and it did not check if the ticks were
visible, or on the spine.
This affects matplotlib.axes.Axes.get_tightbbox in cases where there are
outward ticks with no tick labels, and it also removes the (small) pad around
axes in that case.
Previously, Sankey.add would only accept a single string as the labels
argument if its length is equal to the number of flows, in which case it would
use one character of the string for each flow.
The behavior has been changed to match the documented one: when a single string
is passed, it is used to label all the flows.
Text alignment was previously incorrect, in particular for multiline text
objects with large descenders (i.e. subscripts) and rotated text. These have
been fixed and made more consistent, but could make old code that has
compensated for this no longer have the correct alignment.
Upper case color strings
Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE
characters is deprecated; these colors will become case-sensitive (lowercase)
after the deprecation period has passed.
The goal is to decrease the number of ambiguous cases when using the data
keyword to plotting methods; e.g. plot("X","Y",data={"X":...,"Y":...})
will not warn about "Y" possibly being a color anymore after the deprecation
period has passed.
Degenerate limits
When bounds passed to set_xlim are degenerate (i.e. the
lower and upper value are equal), the method used to "expand" the
bounds now matches the expansion behavior of autoscaling when the plot
contains a single x-value, and should in particular produce nicer
limits for non-linear scales.
In certain cases, plot would previously accept format strings
specifying more than one linestyle (e.g. "---." which specifies both
"--" and "-."); only use one of them would be used. This now raises a
ValueError instead.
HTMLWriter
The HTMLWriter constructor is more strict: it no longer normalizes unknown
values of default_mode to 'loop', but errors out instead.
AFM parsing
In accordance with the AFM spec, the AFM parser no longer truncates the
UnderlinePosition and UnderlineThickness fields to integers.
The Notice field (which can only be publicly accessed by the deprecated
afm.parse_afm API) is no longer decoded to a str, but instead kept as
bytes, to support non-conformant AFM files that use non-ASCII characters in
that field.
Artist.set now normalizes keywords before sorting them. Previously it sorted
its keyword arguments in reverse alphabetical order (with a special-case to
put color at the end) before applying them.
It now normalizes aliases (and, as above, emits a warning on duplicate
properties) before doing the sorting (so c goes to the end too).
Previously Axes.tick_params silently did nothing when an invalid axis
parameter was supplied. This behavior has been changed to raise a ValueError
instead.
Input that consists of multiple empty lists will now return a list of histogram
values for each one of the lists. For example, an input of [[],[]] will
return 2 lists of histogram values. Previously, a single list was returned.
Currently, backend_bases.TimerBase.remove_callback(func,*args,**kwargs) removes a callback previously added by
backend_bases.Timer.add_callback(func,*args,**kwargs), but if
*args,**kwargs is not passed in (i.e.,
TimerBase.remove_callback(func)), then the first callback with a
matching func is removed, regardless of whether it was added with
or without *args,**kwargs.
In a future version, TimerBase.remove_callback will always use the latter
behavior (not consider *args,**kwargs); to specifically consider them, add
the callback as a functools.partial object
TimerBase.add_callback was modified to return func to
simplify the above usage (previously it returned None); this also
allows using it as a decorator.
StemContainer objects can now store a
LineCollection object instead of a list of
Line2D objects for stem lines plotted using
stem. This gives a very large performance boost to displaying
and moving stem plots.
This will become the default behaviour in Matplotlib 3.3. To use it
now, the use_line_collection keyword argument to stem can
be set to True
ax.stem(...,use_line_collection=True)
Individual line segments can be extracted from the
LineCollection using
get_segments(). See the
LineCollection documentation for other methods to
retrieve the collection properties.
matplotlib.colorbar.ColorbarBase is no longer a subclass of
cm.ScalarMappable. This inheritance lead to a confusing situation
where the cm.ScalarMappable passed to matplotlib.colorbar.Colorbar
(colorbar) had a set_norm method, as did the colorbar.
The colorbar is now purely a follower to the ScalarMappable norm and
colormap, and the old inherited methods
matplotlib.colorbar.ColorbarBase.set_norm,
matplotlib.colorbar.ColorbarBase.set_cmap,
matplotlib.colorbar.ColorbarBase.set_clim are deprecated, as are
the getter versions of those calls. To set the norm associated with a
colorbar do colorbar.mappable.set_norm() etc.
FreeType and libpng search paths
The MPLBASEDIRLIST environment variables and basedirlist entry in
setup.cfg have no effect anymore. Instead, if building in situations where
FreeType or libpng are not in the compiler or linker's default path, set the
standard environment variables CFLAGS/LDFLAGS on Linux or OSX, or
CL/LINK on Windows, to indicate the relevant paths.
Setting artist properties twice or more in the same call
Setting the same artist property multiple time via aliases is deprecated.
Previously, code such as
plt.plot([0,1],c="red",color="blue")
would emit a warning indicating that c and color are aliases
of one another, and only keep the color kwarg. This behavior has
been deprecated; in a future version, this will raise a TypeError,
similar to Python's behavior when a keyword argument is passed twice
Path code types like Path.MOVETO are now np.uint8 instead of intPath.STOP, Path.MOVETO, Path.LINETO, Path.CURVE3,
Path.CURVE4 and Path.CLOSEPOLY are now of the type Path.code_type
(np.uint8 by default) instead of plain int. This makes their type
match the array value type of the Path.codes array.
LaTeX code in matplotlibrc file
Previously, the rc file keys pgf.preamble and text.latex.preamble were
parsed using commas as separators. This would break valid LaTeX code, such as:
The parsing has been modified to pass the complete line to the LaTeX system,
keeping all commas. Passing a list of strings from within a Python script still
works as it used to. Passing a list containing non-strings now fails, instead
of coercing the results to strings.
The method Axes.spy now raises a TypeError for the keyword
arguments interpolation and linestyle instead of silently ignoring
them.
Furthermore, Axes.spy spy does now allow for an extent argument
(was silently ignored so far).
A bug with Axes.spy(...,origin='lower') is fixed. Previously this
flipped the data but not the y-axis resulting in a mismatch between
axes labels and actual data indices. Now, origin='lower' flips both
the data and the y-axis labels.
Boxplot tick methods
The manage_xticks parameter of boxplot and bxp has
been renamed (with a deprecation period) to manage_ticks, to take
into account the fact that it manages either x or y ticks depending on
the vert parameter.
When manage_ticks=True (the default), these methods now attempt to
take previously drawn boxplots into account when setting the axis
limits, ticks, and tick labels.
MouseEvents
MouseEvents now include the event name in their str().
Previously they contained the prefix "MPL MouseEvent".
RGBA buffer return type
FigureCanvasAgg.buffer_rgba and RendererAgg.buffer_rgba now
return a memoryview The buffer_rgba method now allows direct
access to the renderer's underlying buffer (as a (m,n,4)-shape
memoryview) rather than copying the data to a new bytestring. This is
consistent with the behavior on Py2, where a buffer object was
returned.
matplotlib.font_manager.win32InstalledFonts return type
matplotlib.font_manager.win32InstalledFonts returns an empty list instead
of None if no fonts are found.
Axes.fmt_xdata and Axes.fmt_ydata error handling
Previously, if the user provided a Axes.fmt_xdata or
Axes.fmt_ydata function that raised a TypeError (or set them to a
non-callable), the exception would be silently ignored and the default
formatter be used instead. This is no longer the case; the exception
is now propagated out.
The gridOn, tick1On, tick2On, label1On, and label2OnTick attributes have been deprecated. Directly get and set the visibility
on the underlying artists, available as the gridline, tick1line,
tick2line, label1, and label2 attributes.
The label attribute, which was an alias for label1, has been
deprecated.
Subclasses that relied on setting the above visibility attributes needs to be
updated; see e.g. examples/api/skewt.py.
Passing a Line2D's drawstyle together with the linestyle is deprecated
Instead of plt.plot(...,linestyle="steps--"), use plt.plot(...,linestyle="--",drawstyle="steps"). ds is now an alias for drawstyle.
pgi support dropped
Support for pgi in the GTK3 backends has been dropped. pgi is
an alternative implementation to PyGObject. PyGObject should
be used instead.
rcParam changes
Removed
The following deprecated rcParams have been removed:
backend.qt4 and backend.qt5 (set the QT_API environment
variable instead)
Deprecated
The associated validator functions rcsetup.validate_qt4 and
validate_qt5 are deprecated.
The verbose.fileo and verbose.level rcParams have been deprecated.
These have had no effect since the switch from Matplotlib's old custom Verbose
logging to the stdlib's logging module. In addition the
rcsetup.validate_verbose function is deprecated.
The text.latex.unicode rcParam now defaults to True and is
deprecated (i.e., in future versions
of Matplotlib, unicode input will always be supported).
Moreover, the underlying implementation now uses \usepackage[utf8]{inputenc}
instead of .
Exception changes
mpl_toolkits.axes_grid1.axes_size.GetExtentHelper now raises ValueError
for invalid directions instead of KeyError.
Previously, subprocess failures in the animation framework would raise either
in a RuntimeError or a ValueError depending on when the error occurred.
They now raise a subprocess.CalledProcessError with attributes set as
documented by the exception class.
In certain cases, Axes methods (and pyplot functions) used to raise
a RuntimeError if they were called with a data kwarg and
otherwise mismatched arguments. They now raise a TypeError
instead.
Axes.streamplot does not support irregularly gridded x and y values.
So far, it used to silently plot an incorrect result. This has been changed to
raise a ValueError instead.
The streamplot.Grid class, which is internally used by streamplot
code, also throws a ValueError when irregularly gridded values are
passed in.
Lots of code inside the matplotlib.mlab module which was deprecated
in Matplotlib 2.2 has been removed. This means the following functions are
no longer available in the pylab module:
Axes3D.voxels now shades the resulting voxels; for more details see
What's new. The previous behavior can be achieved by passing
ax.voxels(..,shade=False)
Equal aspect axes disabled
Setting the aspect on 3D axes previously returned non-sensical results
(e.g. see #1077). Calling ax.set_aspect('equal') or
ax.set_aspect(num) on a 3D axes now raises a
NotImplementedError.
Poly3DCollection.set_zsort no longer silently ignores invalid
inputs, or False (which was always broken). Passing True to mean
"average" is deprecated.
Testing
The --no-network flag to tests.py has been removed (no test requires
internet access anymore). If it is desired to disable internet access both for
old and new versions of Matplotlib, use tests.py-m'notnetwork' (which is
now a no-op).
The image comparison test decorators now skip (rather than xfail) the test for
uncomparable formats. The affected decorators are image_comparison and
check_figures_equal. The deprecated ImageComparisonTest class is
likewise changed.
Dependency changes
NumPy
Matplotlib 3.1 now requires NumPy>=1.11.
ghostscript
Support for ghostscript 8.60 (released in 2007) has been removed. The oldest
supported version of ghostscript is now 9.0 (released in 2010).
Mathtext changes
In constructs such as "$1~2$", mathtext now interprets the tilde as a
space, consistently with TeX (this was previously a parse error).
Deprecations
The \stackrel mathtext command has been deprecated (it behaved differently
from LaTeX's \stackrel. To stack two mathtext expressions, use
\genfrac{left-delim}{right-delim}{fraction-bar-thickness}{}{top}{bottom}.
The \mathcircled mathtext command (which is not a real TeX command)
is deprecated. Directly use unicode characters (e.g.
"\N{CIRCLEDLATINCAPITALLETTERA}" or "\u24b6") instead.
Passing (n, 1)-shaped error arrays to Axes.errorbar(), which was not
documented and did not work for n=2. Pass a 1D array instead.
The frameon keyword argument to savefig and the savefig.frameon
rcParam. To emulate frameon=False, set facecolor to fully
transparent ("none", or (0,0,0,0)).
Passing a non-1D (typically, (n, 1)-shaped) input to Axes.pie.
Pass a 1D array instead.
The TextPath constructor used to silently drop ignored arguments; this
behavior is deprecated.
The usetex parameter of TextToPath.get_text_path is deprecated and
folded into the ismath parameter, which can now take the values
False, True, and "TeX", consistently with other low-level
text processing functions.
Passing 'normal' to axes.Axes.axis() is deprecated, use
ax.axis('auto') instead.
Passing the block argument of pyplot.show positionally is deprecated; it
should be passed by keyword.
When using the nbagg backend, pyplot.show used to silently accept and ignore
all combinations of positional and keyword arguments. This behavior is
deprecated.
The unused shape and imlim parameters to Axes.imshow are
deprecated. To avoid triggering the deprecation warning, the filternorm,
filterrad, resample, and url arguments should be passed by
keyword.
The interp_at_native parameter to BboxImage, which has had no effect
since Matplotlib 2.0, is deprecated.
All arguments to the matplotlib.cbook.deprecation.deprecated decorator
and matplotlib.cbook.deprecation.warn_deprecated function, except the
first one (the version where the deprecation occurred), are now keyword-only.
The goal is to avoid accidentally setting the "message" argument when the
"name" (or "alternative") argument was intended, as this has repeatedly
occurred in the past.
Passing positional arguments to Axis.set_ticklabels beyond ticklabels
itself has no effect, and support for them is deprecated.
Passing shade=None to plot_surface is deprecated. This
was an unintended implementation detail with the same semantics as
shade=False. Please use the latter code instead.
matplotlib.ticker.MaxNLocator and its set_params method will issue
a warning on unknown keyword arguments instead of silently ignoring them.
Future versions will raise an error.
Changes in parameter names
The arg parameter to matplotlib.use has been renamed to backend.
This will only affect cases where that parameter has been set
as a keyword argument. The common usage pattern as a positional argument
matplotlib.use('Qt5Agg') is not affected.
The normed parameter to Axes.hist2d has been renamed to density.
In each case, the old parameter name remains supported (it cannot be used
simultaneously with the new name), but support for it will be dropped in
Matplotlib 3.3.
Class/method/attribute deprecations
Support for custom backends that do not provide a
GraphicsContextBase.set_hatch_color method is deprecated. We
suggest that custom backends let their GraphicsContext class
inherit from GraphicsContextBase, to at least provide stubs for all
required methods.
spine.Spine.is_frame_like
This has not been used in the codebase since its addition in 2009.
axis3d.Axis.get_tick_positions
This has never been used internally, there is no equivalent method exists on
the 2D Axis classes, and despite the similar name, it has a completely
different behavior from the 2D Axis' axis.Axis.get_ticks_position method.
.TextToPath.glyph_to_path (Instead call font.get_path() and manually
transform the path.)
Date related functions
dates.seconds()
dates.minutes()
dates.hours()
dates.weeks()
dates.strpdate2num
dates.bytespdate2num
These are brittle in the presence of locale changes. Use standard datetime
parsers such as time.strptime or , and additionally
call if you need to convert to Matplotlib's
internal datetime representation; or use .
Axes3D
.axes3d.Axes3D.w_xaxis
.axes3d.Axes3D.w_yaxis
.axes3d.Axes3D.w_zaxis
Use axes3d.Axes3D.xaxis, axes3d.Axes3D.yaxis and
axes3d.Axes3D.zaxis instead.
Instead, use (as for any Collection) the get_facecolor method.
Note that setting to the .color attribute did not update the quiver artist,
whereas calling set_facecolor does.
.NavigationToolbar2QT.adj_window attribute. This is unused and always None.
.backend_wx.IDLE_DELAY global variable
This is unused and only relevant to the now removed wx "idling" code (note that
as it is a module-level global, no deprecation warning is emitted when
accessing it).
Transforms / scales
LogTransformBase
Log10Transform
Log2Transform,
NaturalLogTransformLog
InvertedLogTransformBase
InvertedLog10Transform
InvertedLog2Transform
InvertedNaturalLogTransform
These classes defined in are deprecated.
As a replacement, use the general and
classes, whose constructors take a argument.
Locators / Formatters
OldScalarFormatter.pprint_val
ScalarFormatter.pprint_val
LogFormatter.pprint_val
These are helper methods that do not have a consistent signature across
formatter classes.
This is because the matplotlib.sphinxext.mathmpl and
matplotlib.sphinxext.plot_directive interfaces have changed from the
(Sphinx-)deprecated function-based interface to a class-based interface; this
should not affect end users.
The Formatter class gained a new format_ticks method, which
takes the list of all tick locations as a single argument and returns the list
of all formatted values. It is called by the axis tick handling code and, by
default, first calls set_locs with all locations, then repeatedly
calls Formatter.__call__ for each location.
Tick-handling code in the codebase that previously performed this sequence
( followed by repeated ) have been
updated to use .
Added support for RGB(A) images in pcolorfast
pcolorfast now accepts 3D images (RGB or RGBA) arrays if the X and Y
specifications allow image or pcolorimage rendering; they remain unsupported by
the more general quadmesh rendering
Invalid inputs
Passing invalid locations to legend and table used
to fallback on a default location. This behavior is deprecated and
will throw an exception in a future version.
offsetbox.AnchoredText is unable to handle the horizontalalignment or
verticalalignment kwargs, and used to ignore them with a warning. This
behavior is deprecated and will throw an exception in a future version.
Passing steps less than 1 or greater than 10 to MaxNLocator used to
result in undefined behavior. It now throws a ValueError.
The signature of the (private) Axis._update_ticks has been changed to not
take the renderer as argument anymore (that argument is unused).
format_ticks is intended to be overridden by Formatter
subclasses for which the formatting of a tick value depends on other tick
values, such as ConciseDateFormatter.