API Changes in 2.1.0#
Default behavior of log scales changed to mask <= 0 values#
now uses 'mask' as the default method to handle invalid values (as opposed to
'clip'). This means that any values <= 0 on a log scale will not be shown.
Previously they were clipped to a very small number and shown.
matplotlib.cbook.CallbackRegistry.process() suppresses exceptions by default#
Matplotlib uses instances of
as a bridge between user input event from the GUI and user callbacks.
Previously, any exceptions raised in a user call back would bubble out
process method, which is typically in the GUI event
loop. Most GUI frameworks simple print the traceback to the screen
and continue as there is not always a clear method of getting the
exception back to the user. However PyQt5 now exits the process when
it receives an un-handled python exception in the event loop. Thus,
process() now suppresses and
prints tracebacks to stderr by default.
process() does with exceptions
is now user configurable via the
exception_handler attribute and kwarg. To
restore the previous behavior pass
cb = CallbackRegistry(exception_handler=None)
A function which take and
Exception as its only argument may also be passed
def maybe_reraise(exc): if isinstance(exc, RuntimeError): pass else: raise exc cb = CallbackRegistry(exception_handler=maybe_reraise)
Improved toggling of the axes grids#
g key binding now switches the states of the
independently (by cycling through all four on/off combinations).
G key binding switches the states of the minor grids.
Both bindings are disabled if only a subset of the grid lines (in either direction) is visible, to avoid making irreversible changes to the figure.
Ticklabels are turned off instead of being invisible#
is now used to hide tick labels instead of setting the visibility on the tick
This improves overall performance and fixes some issues.
As a consequence, in case those labels ought to be shown,
needs to be used, e.g.
Removal of warning on empty legends#
pyplot.legend used to issue a warning when no labeled artist could be
found. This warning has been removed.
More accurate legend autopositioning#
Automatic positioning of legends now prefers using the area surrounded
Line2D rather than placing the legend over the line itself.
Cleanup of stock sample data#
The sample data of stocks has been cleaned up to remove redundancies and
increase portability. The
files have been removed entirely and will also no longer be available from
matplotlib.cbook.get_sample_data. If a CSV file is required, we suggest using
msft.csv that continues to be shipped in the sample data. If a NumPy
binary file is acceptable, we suggest using one of the following two new files.
goog.npy files have been replaced by
goog.npz, wherein the first column's type has changed from
numpy.datetime64 for better portability across Python
versions. Note that Matplotlib does not fully support
Updated qhull to 2015.2#
The version of qhull shipped with Matplotlib, which is used for Delaunay triangulation, has been updated from version 2012.1 to 2015.2.
Improved Delaunay triangulations with large offsets#
Delaunay triangulations now deal with large x,y offsets in a better
way. This can cause minor changes to any triangulations calculated
using Matplotlib, i.e. any use of
requests that a Delaunay triangulation is calculated, which includes
backports.functools_lru_cache instead of
It's better maintained and more widely used (by pylint, jaraco, etc).
cbook.is_numlike only performs an instance check#
matplotlib.cbook.is_numlike now only checks that its argument
is an instance of
(numbers.Number, np.Number). In particular,
this means that arrays are now not num-like.
Elliptical arcs now drawn between correct angles#
matplotlib.patches.Arc patch is now correctly drawn between the given
Previously a circular arc was drawn and then stretched into an ellipse, so the resulting arc did not lie between theta1 and theta2.
-d$backend no longer sets the backend#
It is no longer possible to set the backend by passing
at the command line. Use the
MPLBACKEND environment variable
Path.intersects_bbox always treats the bounding box as filled#
Path.intersects_bbox was called with
filled set to
False, it would treat both the path and the bounding box as unfilled. This
behavior was not well documented and it is usually not the desired behavior,
since bounding boxes are used to represent more complex shapes located inside
the bounding box. This behavior has now been changed: when
False, the path will be treated as unfilled, but the bounding box is still
treated as filled. The old behavior was arguably an implementation bug.
Path.intersects_bbox is called with
filled set to
(the default value), there is no change in behavior. For those rare cases where
Path.intersects_bbox was called with
filled set to
False and where
the old behavior is actually desired, the suggested workaround is to call
Path.intersects_path with a rectangle as the path:
from matplotlib.path import Path from matplotlib.transforms import Bbox, BboxTransformTo rect = Path.unit_rectangle().transformed(BboxTransformTo(bbox)) result = path.intersects_path(rect, filled=False)
WX no longer calls generates
IdleEvent events or calls
Removed unused private method
IdleEvent class and
will be removed in 2.2
Correct scaling of
matplotlib.pyplot.magnitude_spectrum() implicitly assumed the sum
of windowing function values to be one. In Matplotlib and Numpy the
standard windowing functions are scaled to have maximum value of one,
which usually results in a sum of the order of n/2 for a n-point
signal. Thus the amplitude scaling
off by that amount when using standard windowing functions (Bug 8417 ). Now the
behavior is consistent with
scipy.signal.welch(). The following example demonstrates the
new and old scaling:
import matplotlib.pyplot as plt import numpy as np tau, n = 10, 1024 # 10 second signal with 1024 points T = tau/n # sampling interval t = np.arange(n)*T a = 4 # amplitude x = a*np.sin(40*np.pi*t) # 20 Hz sine with amplitude a # New correct behavior: Amplitude at 20 Hz is a/2 plt.magnitude_spectrum(x, Fs=1/T, sides='onesided', scale='linear') # Original behavior: Amplitude at 20 Hz is (a/2)*(n/2) for a Hanning window w = np.hanning(n) # default window is a Hanning window plt.magnitude_spectrum(x*np.sum(w), Fs=1/T, sides='onesided', scale='linear')
Change to signatures of
For 2.0 the default value of *align* changed to
'center'. However this caused the signature of
barh() to be misleading as the first parameters were
still left and bottom respectively:
bar(left, height, *, align='center', **kwargs) barh(bottom, width, *, align='center', **kwargs)
despite behaving as the center in both cases. The methods now take
*args, **kwargs as input and are documented to have the primary
bar(x, height, *, align='center', **kwargs) barh(y, width, *, align='center', **kwargs)
Passing left and bottom as keyword arguments to
barh() respectively will warn.
Support will be removed in Matplotlib 3.0.
Font cache as json#
The font cache is now saved as json, rather than a pickle.
Invalid (Non-finite) Axis Limit Error#
set_ylim(), passing non-finite values now
results in a
ValueError. The previous behavior resulted in the
limits being erroneously reset to
Collection offsets are no longer implicitly flattened#
Collection (and thus both 2D
scatter and 3D
longer implicitly flattens its offsets. As a consequence,
y arguments can no longer be 2+-dimensional arrays.
GraphicsContextBase.set_linestyle methods, which had no effect,
have been deprecated. All of the backends Matplotlib ships use
GraphicsContextBase.set_dashes which are more general.
Third-party backends should also migrate to the
matplotlib.testing.noseclasses is deprecated and will be removed in 2.3
EngFormatter num arg as string#
Passing a string as num argument when calling an instance of
matplotlib.ticker.EngFormatter is deprecated and will be removed in 2.3.
All functionally from
mpl_toolkits.axes_grid can be found in either
mpl_toolkits.axisartist. Axes classes
mpl_toolkits.axes_grid based on
mpl_toolkits.axisartist can be found in
Axes collision in
Adding an axes instance to a figure by using the same arguments as for
a previous axes instance currently reuses the earlier instance. This
behavior has been deprecated in Matplotlib 2.1. In a future version, a
new instance will always be created and returned. Meanwhile, in such
a situation, a deprecation warning is raised by
This warning can be suppressed, and the future behavior ensured, by passing
a unique label to each axes instance. See the docstring of
add_axes() for more information.
Additional details on the rationale behind this deprecation can be found in #7377 and #9024.
Former validators for
The former public validation functions
validate_negative_linestyle_legacy will be deprecated in 2.1 and
may be removed in 2.3. There are no public functions to replace them.
Many unused or near-unused
matplotlib.cbook functions and
classes have been deprecated:
qt_compat.py. Renamed because it now handles Qt5 as well.
Previously Deprecated methods#
mpl_toolkits.axes_grid1.mpl_axes.Axes.toggle_axisline methods have been
ArtistInspector.findobj method, which was never working due to the lack
get_children method, has been removed.
functions in the
matplotlib.path module have been removed. Their
functionality remains exposed as methods on the
have been removed
matplotlib.backends.backend_ps.seq_allequal function has been removed.
matplotlib.rcsetup.validate_tkpythoninspect functions, and associated
tk.pythoninspect rcparams entries have been
The keyword argument resolution of
matplotlib.projections.polar.PolarAxes has been removed. It
has deprecation with no effect from version 0.98.x.
Support for setting an
Axes's aspect to
"normal" has been
removed, in favor of the synonym
shading kwarg to
shading kwarg to
pcolor has been
edgecolors appropriately instead.
Functions removed from the
matplotlib.lines module no longer imports the
PDF backend functions#
matplotlib.backends.backend_pdf.PdfFile have been removed. It is
unlikely that external users would have called these methods, which
are related to the font system internal to the PDF backend.
Remove the delaunay triangulation code which is now handled by Qhull