Changes in 1.3.x¶
Changes in 1.3.1¶
It is rare that we make an API change in a bugfix release, however, for 1.3.1 since 1.3.0 the following change was made:
text.Text.cached(used to cache font objects) has been made into a private variable. Among the obvious encapsulation benefit, this removes this confusing-looking member from the documentation.- The method
hist()now always returns bin occupancies as an array of typefloat. Previously, it was sometimes an array of typeint, depending on the call.
Code removal¶
The following items that were deprecated in version 1.2 or earlier have now been removed completely.
The Qt 3.x backends (
qtandqtagg) have been removed in favor of the Qt 4.x backends (qt4andqt4agg).The FltkAgg and Emf backends have been removed.
The
matplotlib.nxutilsmodule has been removed. Use the functionality onmatplotlib.path.Path.contains_pointand friends instead.Instead of
axes.Axes.get_frame, useaxes.Axes.patch.The following keyword arguments to the
legendfunction have been renamed:- pad -> borderpad
- labelsep -> labelspacing
- handlelen -> handlelength
- handletextsep -> handletextpad
- axespad -> borderaxespad
Related to this, the following rcParams have been removed:
legend.pad,legend.labelsep,legend.handlelen,legend.handletextsepandlegend.axespad
For the
histfunction, instead of width, use rwidth (relative width).On
patches.Circle, the resolution keyword argument has been removed. For a circle made up of line segments, usepatches.CirclePolygon.The printing functions in the Wx backend have been removed due to the burden of keeping them up-to-date.
mlab.liaupunovhas been removed.mlab.save,mlab.load,pylab.saveandpylab.loadhave been removed. We recommend usingnumpy.savetxtandnumpy.loadtxtinstead.widgets.HorizontalSpanSelectorhas been removed. Usewidgets.SpanSelectorinstead.
Code deprecation¶
The CocoaAgg backend has been deprecated, with the possibility for deletion or resurrection in a future release.
The top-level functions in
matplotlib.paththat are implemented in C++ were never meant to be public. Instead, users should use the Pythonic wrappers for them in thepath.Pathandcollections.Collectionclasses. Use the following mapping to update your code:point_in_path->path.Path.contains_pointget_path_extents->path.Path.get_extentspoint_in_path_collection->collections.Collection.containspath_in_path->path.Path.contains_pathpath_intersects_path->path.Path.intersects_pathconvert_path_to_polygons->path.Path.to_polygonscleanup_path->path.Path.cleanedpoints_in_path->path.Path.contains_pointsclip_path_to_rect->path.Path.clip_to_bbox
matplotlib.colors.normalizeandmatplotlib.colors.no_normhave been deprecated in favour ofmatplotlib.colors.Normalizeandmatplotlib.colors.NoNormrespectively.The
ScalarMappableclass'set_colorbarmethod is now deprecated. Instead, thematplotlib.cm.ScalarMappable.colorbarattribute should be used. In previous Matplotlib versions this attribute was an undocumented tuple of(colorbar_instance, colorbar_axes)but is now justcolorbar_instance. To get the colorbar axes it is possible to just use theaxattribute on a colorbar instance.The
matplotlib.mplmodule is now deprecated. Those who relied on this module should transition to simply usingimport matplotlib as mpl.
Code changes¶
Patchnow fully supports using RGBA values for itsfacecolorandedgecolorattributes, which enables faces and edges to have different alpha values. If thePatchobject'salphaattribute is set to anything other thanNone, that value will override any alpha-channel value in both the face and edge colors. Previously, ifPatchhadalpha=None, the alpha component ofedgecolorwould be applied to both the edge and face.The optional
isRGBargument toset_foreground()(and the other GraphicsContext classes that descend from it) has been renamed toisRGBA, and should now only be set toTrueif thefgcolor argument is known to be an RGBA tuple.For
Patch, thecapstyleused is nowbutt, to be consistent with the default for most other objects, and to avoid problems with non-solidlinestyleappearing solid when using a largelinewidth. Previously,Patchusedcapstyle='projecting'.Pathobjects can now be marked as readonly by passingreadonly=Trueto its constructor. The built-in path singletons, obtained throughPath.unit*class methods return readonly paths. If you have code that modified these, you will need to make a deepcopy first, using either:import copy path = copy.deepcopy(Path.unit_circle()) # or path = Path.unit_circle().deepcopy()
Deep copying a
Pathalways creates an editable (i.e. non-readonly)Path.The list at
Path.NUM_VERTICESwas replaced by a dictionary mapping Path codes to the number of expected vertices atNUM_VERTICES_FOR_CODE.To support XKCD style plots, the
matplotlib.path.cleanup_pathmethod's signature was updated to require a sketch argument. Users ofmatplotlib.path.cleanup_pathare encouraged to use the newcleaned()Path method.Data limits on a plot now start from a state of having "null" limits, rather than limits in the range (0, 1). This has an effect on artists that only control limits in one direction, such as
axes.Axes.axvlineandaxes.Axes.axhline, since their limits will no longer also include the range (0, 1). This fixes some problems where the computed limits would be dependent on the order in which artists were added to the axes.Fixed a bug in setting the position for the right/top spine with data position type. Previously, it would draw the right or top spine at +1 data offset.
In
FancyArrow, the default arrow head width,head_width, has been made larger to produce a visible arrow head. The new value of this kwarg ishead_width = 20 * width.It is now possible to provide
number of levels + 1colors in the case ofextend='both'for contourf (or justnumber of levelscolors for an extend valueminormax) such that the resulting colormap'sset_underandset_overare defined appropriately. Any other number of colors will continue to behave as before (if more colors are provided than levels, the colors will be unused). A similar change has been applied to contour, whereextend='both'would expectnumber of levels + 2colors.A new keyword extendrect in
colorbar()andColorbarBaseallows one to control the shape of colorbar extensions.The extension of
MultiCursorto both vertical (default) and/or horizontal cursor implied thatself.lineis replaced byself.vlinefor vertical cursors lines andself.hlineis added for the horizontal cursors lines.On POSIX platforms, the
report_memory()function raisesNotImplementedErrorinstead ofOSErrorif the ps command cannot be run.The
matplotlib.cbook.check_outputfunction has been moved tomatplotlib.compat.subprocess.
Configuration and rcParams¶
- On Linux, the user-specific
matplotlibrcconfiguration file is now located in~/.config/matplotlib/matplotlibrcto conform to the XDG Base Directory Specification. - The
font.*rcParams now affect only text objects created after the rcParam has been set, and will not retroactively affect already existing text objects. This brings their behavior in line with most other rcParams. - Removed call of
grid()inmatplotlib.pyplot.plotfile. To draw the axes grid, set theaxes.gridrcParam to True, or explicitly callgrid().