Changes in 1.4.x¶
Code changes¶
A major refactoring of the axes module was made. The axes module has been split into smaller modules:
- the
_basemodule, which contains a new private_AxesBaseclass. This class contains all methods except plotting and labelling methods. - the
axesmodule, which contains theaxes.Axesclass. This class inherits from_AxesBase, and contains all plotting and labelling methods. - the
_subplotmodule, with all the classes concerning subplotting.
- the
There are a couple of things that do not exists in the axes
module's namespace anymore. If you use them, you need to import them from their
original location:
math->import mathma->from numpy import macbook->from matplotlib import cbookdocstring->from matplotlib import docstringis_sequence_of_strings->from matplotlib.cbook import is_sequence_of_stringsis_string_like->from matplotlib.cbook import is_string_likeiterable->from matplotlib.cbook import iterableitertools->import itertoolsmartist->from matplotlib import artist as martistmatplotlib->import matplotlibmcoll->from matplotlib import collections as mcollmcolors->from matplotlib import colors as mcolorsmcontour->from matplotlib import contour as mcontourmpatches->from matplotlib import patches as mpatchesmpath->from matplotlib import path as mpathmquiver->from matplotlib import quiver as mquivermstack->from matplotlib import stack as mstackmstream->from matplotlib import stream as mstreammtable->from matplotlib import table as mtable
As part of the refactoring to enable Qt5 support, the module
matplotlib.backends.qt4_compatwas renamed tomatplotlib.backends.qt_compat.qt4_compatis deprecated in 1.4 and will be removed in 1.5.The
errorbar()method has been changed such that the upper and lower limits (lolims, uplims, xlolims, xuplims) now point in the correct direction.The fmt kwarg for
errorbar()now supports the string 'none' to suppress drawing of a line and markers; use of the None object for this is deprecated. The default fmt value is changed to the empty string (''), so the line and markers are governed by theplot()defaults.A bug has been fixed in the path effects rendering of fonts, which now means that the font size is consistent with non-path effect fonts. See https://github.com/matplotlib/matplotlib/issues/2889 for more detail.
The Sphinx extensions
ipython_directiveandipython_console_highlightinghave been moved to the IPython project itself. While they remain in Matplotlib for this release, they have been deprecated. Update your extensions inconf.pyto point toIPython.sphinxext.ipython_directiveinstead ofmatplotlib.sphinxext.ipython_directive.In
matplotlib.finance, almost all functions have been deprecated and replaced with a pair of functions name*_ochland*_ohlc. The former is the 'open-close-high-low' order of quotes used previously in this module, and the latter is the 'open-high-low-close' order that is standard in finance.For consistency the
face_alphakeyword tomatplotlib.patheffects.SimplePatchShadowhas been deprecated in favour of thealphakeyword. Similarly, the keywordoffset_xyis now namedoffsetacross allAbstractPathEffects.matplotlib.patheffects._Basehas been renamed tomatplotlib.patheffects.AbstractPathEffect.matplotlib.patheffect.ProxyRendererhas been renamed tomatplotlib.patheffects.PathEffectRendererand is now a full RendererBase subclass.The artist used to draw the outline of a
Figure.colorbarhas been changed from amatplotlib.lines.Line2Dtomatplotlib.patches.Polygon, thuscolorbar.ColorbarBase.outlineis now amatplotlib.patches.Polygonobject.The legend handler interface has changed from a callable, to any object which implements the
legend_artistsmethod (a deprecation phase will see this interface be maintained for v1.4). See Legend guide for further details. Further legend changes include:matplotlib.axes.Axes._get_legend_handlesnow returns a generator of handles, rather than a list.- The
legend()function's loc positional argument has been deprecated. Use the loc keyword argument instead.
The
rcParams["savefig.transparent"](default:False) has been added to control default transparency when saving figures.Slightly refactored the
Annotationfamily. The text location inAnnotationis now entirely handled by the underlyingTextobject so.set_positionworks as expected. The attributes xytext and textcoords have been deprecated in favor of xyann and anncoords so thatAnnotationandAnnotationBboxcan share a common sensibly named api for getting/setting the location of the text or box.- xyann -> set the location of the annotation
- xy -> set where the arrow points to
- anncoords -> set the units of the annotation location
- xycoords -> set the units of the point location
set_position()->Annotationonly set location of annotation
matplotlib.mlab.specgram,matplotlib.mlab.psd,matplotlib.mlab.csd,matplotlib.mlab.cohere,matplotlib.mlab.cohere_pairs,matplotlib.pyplot.specgram,matplotlib.pyplot.psd,matplotlib.pyplot.csd, andmatplotlib.pyplot.coherenow raise ValueError where they previously raised AssertionError.For
matplotlib.mlab.psd,matplotlib.mlab.csd,matplotlib.mlab.cohere,matplotlib.mlab.cohere_pairs,matplotlib.pyplot.specgram,matplotlib.pyplot.psd,matplotlib.pyplot.csd, andmatplotlib.pyplot.cohere, in cases where a shape (n, 1) array is returned, this is now converted to a (n, ) array. Previously, (n, m) arrays were averaged to an (n, ) array, but (n, 1) arrays were returned unchanged. This change makes the dimensions consistent in both cases.Added the
rcParams["axes.formatter.useoffset"](default:True) to control the default value of useOffset inticker.ScalarFormatterAdded
Formattersub-classStrMethodFormatterwhich does the exact same thing asFormatStrFormatter, but for new-style formatting strings.Deprecated
matplotlib.testing.image_utiland the only function within,matplotlib.testing.image_util.autocontrast. These will be removed completely in v1.5.0.The
fmtargument ofplot_date()has been changed fromboto justo, so color cycling can happen by default.Removed the class
FigureManagerQTAggand deprecatedNavigationToolbar2QTAggwhich will be removed in 1.5.Removed formerly public (non-prefixed) attributes
rectanddrawRectfromFigureCanvasQTAgg; they were always an implementation detail of the (preserved)drawRectangle()function.The function signatures of
tight_bbox.adjust_bboxandtight_bbox.process_figure_for_rasterizinghave been changed. A new fixed_dpi parameter allows for overriding thefigure.dpisetting instead of trying to deduce the intended behaviour from the file format.Added support for horizontal/vertical axes padding to
mpl_toolkits.axes_grid1.axes_grid.ImageGrid--- argument axes_pad can now be tuple-like if separate axis padding is required. The original behavior is preserved.Added support for skewed transforms to
matplotlib.transforms.Affine2D, which can be created using theskewandskew_degmethods.Added clockwise parameter to control sectors direction in
axes.Axes.pieIn
matplotlib.lines.Line2Dthe markevery functionality has been extended. Previously an integer start-index and stride-length could be specified using either a two-element-list or a two-element-tuple. Now this can only be done using a two-element-tuple. If a two-element-list is used then it will be treated as NumPy fancy indexing and only the two markers corresponding to the given indexes will be shown.Removed prop keyword argument from
mpl_toolkits.axes_grid1.anchored_artists.AnchoredSizeBarcall. It was passed through to the base-class__init__and is only used for setting padding. Now fontproperties (which is what is really used to set the font properties ofAnchoredSizeBar) is passed through in place of prop. If fontproperties is not passed in, but prop is, then prop is used in place of fontproperties. If both are passed in, prop is silently ignored.The use of the index 0 in
pyplot.subplotand related commands is deprecated. Due to a lack of validation, callingplt.subplots(2, 2, 0)does not raise an exception, but puts an axes in the _last_ position. This is due to the indexing in subplot being 1-based (to mirror MATLAB) so before indexing into theGridSpecobject used to determine where the axes should go, 1 is subtracted off. Passing in 0 results in passing -1 toGridSpecwhich results in getting the last position back. Even though this behavior is clearly wrong and not intended, we are going through a deprecation cycle in an abundance of caution that any users are exploiting this 'feature'. The use of 0 as an index will raise a warning in 1.4 and an exception in 1.5.Clipping is now off by default on offset boxes.
Matplotlib now uses a less-aggressive call to
gc.collect(1)when closing figures to avoid major delays with large numbers of user objects in memory.The default clip value of all pie artists now defaults to
False.
Code removal¶
- Removed
mlab.levypdf. The code raised a NumPy error (and has for a long time) and was not the standard form of the Levy distribution.scipy.stats.levyshould be used instead