Skip to content

Commit ddfa235

Browse files
authored
Merge pull request #9069 from tacaswell/doc_21_api_changes
Doc: 2.1 api changes and whats_new doc merge up
2 parents d08d584 + c53f055 commit ddfa235

File tree

57 files changed

+935
-820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+935
-820
lines changed

doc/api/api_changes.rst

+287
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,293 @@ out what caused the breakage and how to fix it by updating your code.
1010
For new features that were added to Matplotlib, please see
1111
:ref:`whats-new`.
1212

13+
API Changes in 2.1.0
14+
====================
15+
16+
`mpl_toolkits.axes_grid` has been deprecated
17+
--------------------------------------------
18+
19+
All functionallity from `mpl_toolkits.axes_grid` can be found in either
20+
`mpl_toolkits.axes_grid1` or `mpl_toolkits.axisartist`. Axes classes from
21+
`mpl_toolkits.axes_grid` based on `Axis` from `mpl_toolkits.axisartist` can be
22+
found in `mpl_toolkits.axisartist`
23+
24+
25+
Improved toggling of the axes grids
26+
-----------------------------------
27+
28+
The `g` key binding now switches the states of the `x` and `y` grids
29+
independently (by cycling through all four on/off combinations).
30+
31+
The new `G` key binding switches the states of the minor grids.
32+
33+
Both bindings are disabled if only a subset of the grid lines (in either
34+
direction) is visible, to avoid making irreversible changes to the figure.
35+
36+
37+
Removal of warning on empty legends
38+
-----------------------------------
39+
40+
``plt.legend`` used to issue a warning when no labeled artist could be
41+
found. This warning has been removed.
42+
43+
44+
More accurate legend autopositioning
45+
------------------------------------
46+
47+
Automatic positioning of legends now prefers using the area surrounded
48+
by a `Line2D` rather than placing the legend over the line itself.
49+
50+
51+
Cleanup of stock sample data
52+
----------------------------
53+
54+
The sample data of stocks has been cleaned up to remove redundancies and
55+
increase portability. The ``AAPL.dat.gz``, ``INTC.dat.gz`` and ``aapl.csv``
56+
files have been removed entirely and will also no longer be available from
57+
`matplotlib.cbook.get_sample_data`. If a CSV file is required, we suggest using
58+
the ``msft.csv`` that continues to be shipped in the sample data. If a NumPy
59+
binary file is acceptable, we suggest using one of the following two new files.
60+
The ``aapl.npy.gz`` and ``goog.npy`` files have been replaced by ``aapl.npz``
61+
and ``goog.npz``, wherein the first column's type has changed from
62+
`datetime.date` to `np.datetime64` for better portability across Python
63+
versions. Note that matplotlib does not fully support `np.datetime64` as yet.
64+
65+
66+
Updated qhull to 2015.2
67+
-----------------------
68+
69+
The version of qhull shipped with Matplotlib, which is used for
70+
Delaunay triangulation, has been updated from version 2012.1 to
71+
2015.2.
72+
73+
74+
Use backports.functools_lru_cache instead of functools32
75+
--------------------------------------------------------
76+
77+
It's better maintained and more widely used (by pylint, jaraco, etc).
78+
79+
80+
`cbook.is_numlike` only performs an instance check, `cbook.is_string_like` is deprecated
81+
----------------------------------------------------------------------------------------
82+
83+
`cbook.is_numlike` now only checks that its argument is an instance of
84+
``(numbers.Number, np.Number)``. In particular, this means that arrays are now
85+
not num-like.
86+
87+
`cbook.is_string_like` and `cbook.is_sequence_of_strings` have been
88+
deprecated. Use ``isinstance(obj, six.string_types)`` and ``iterable(obj) and
89+
all(isinstance(o, six.string_types) for o in obj)`` instead.
90+
91+
92+
Elliptical arcs now drawn between correct angles
93+
------------------------------------------------
94+
95+
The `matplotlib.patches.Arc` patch is now correctly drawn between the given
96+
angles.
97+
98+
Previously a circular arc was drawn and then stretched into an ellipse,
99+
so the resulting arc did not lie between *theta1* and *theta2*.
100+
101+
102+
Changes to PDF backend methods
103+
------------------------------
104+
105+
The methods `embedTeXFont` and `tex_font_mapping` of
106+
`matplotlib.backend_pdf.PdfFile` have been removed.
107+
It is unlikely that external users would have called
108+
these methods, which are related to the font system
109+
internal to the PDF backend.
110+
111+
112+
``-d$backend`` no longer sets the backend
113+
-----------------------------------------
114+
115+
It is no longer possible to set the backend by passing ``-d$backend`` at the command line. Use the ``MPLBACKEND`` environment variable instead.
116+
117+
118+
Path.intersects_bbox always treats the bounding box as filled
119+
-------------------------------------------------------------
120+
121+
Previously, when ``Path.intersects_bbox`` was called with ``filled`` set to
122+
``False``, it would treat both the path and the bounding box as unfilled. This
123+
behavior was not well documented and it is usually not the desired behavior,
124+
since bounding boxes are used to represent more complex shapes located inside
125+
the bounding box. This behavior has now been changed: when ``filled`` is
126+
``False``, the path will be treated as unfilled, but the bounding box is still
127+
treated as filled. The old behavior was arguably an implementation bug.
128+
129+
When ``Path.intersects_bbox`` is called with ``filled`` set to ``True``
130+
(the default value), there is no change in behavior. For those rare cases where
131+
``Path.intersects_bbox`` was called with ``filled`` set to ``False`` and where
132+
the old behavior is actually desired, the suggested workaround is to call
133+
``Path.intersects_path`` with a rectangle as the path::
134+
135+
from matplotlib.path import Path
136+
from matplotlib.transforms import Bbox, BboxTransformTo
137+
rect = Path.unit_rectangle().transformed(BboxTransformTo(bbox))
138+
result = path.intersects_path(rect, filled=False)
139+
140+
141+
Removed resolution kwarg from PolarAxes
142+
---------------------------------------
143+
144+
The kwarg `resolution` of `matplotlib.projections.polar.PolarAxes` has been
145+
removed. It has triggered a deprecation warning of being with no effect
146+
beyond version `0.98.x`.
147+
148+
149+
Deprecation of `GraphicsContextBase`\'s ``linestyle`` property.
150+
---------------------------------------------------------------
151+
152+
The ``GraphicsContextBase.get_linestyle`` and
153+
``GraphicsContextBase.set_linestyle`` methods, which effectively had no effect,
154+
have been deprecated.
155+
156+
157+
NavigationToolbar2.dynamic_update is deprecated
158+
-----------------------------------------------
159+
160+
Use `FigureCanvas.draw_idle` instead.
161+
162+
163+
Unique identifier added to `RendererBase` classes
164+
-------------------------------------------------
165+
166+
Since ``id()`` is not guaranteed to be unique between objects that exist at
167+
different times, a new private property ``_uid`` has been added to
168+
`RendererBase` which is used along with the renderer's ``id()`` to cache
169+
certain expensive operations.
170+
171+
If a custom renderer does not subclass `RendererBase` or `MixedModeRenderer`,
172+
it is not required to implement this ``_uid`` property, but this may produce
173+
incorrect behavior when the renderers' ``id()`` clashes.
174+
175+
176+
WX no longer calls generates ``IdleEvent`` events or calls ``idle_event``
177+
-------------------------------------------------------------------------
178+
179+
Removed unused private method ``_onIdle`` from ``FigureCanvasWx``.
180+
181+
The ``IdleEvent`` class and ``FigureCanvasBase.idle_event`` method
182+
will be removed in 2.2
183+
184+
185+
Correct scaling of :func:`magnitude_spectrum()`
186+
-----------------------------------------------
187+
188+
The functions :func:`matplotlib.mlab.magnitude_spectrum()` and :func:`matplotlib.pyplot.magnitude_spectrum()` implicitly assumed the sum
189+
of windowing function values to be one. In Matplotlib and Numpy the
190+
standard windowing functions are scaled to have maximum value of one,
191+
which usually results in a sum of the order of n/2 for a n-point
192+
signal. Thus the amplitude scaling :func:`magnitude_spectrum()` was
193+
off by that amount when using standard windowing functions (`Bug 8417
194+
<https://github.com/matplotlib/matplotlib/issues/8417>`_ ). Now the
195+
behavior is consistent with :func:`matplotlib.pyplot.psd()` and
196+
:func:`scipy.signal.welch()`. The following example demonstrates the
197+
new and old scaling::
198+
199+
import matplotlib.pyplot as plt
200+
import numpy as np
201+
202+
tau, n = 10, 1024 # 10 second signal with 1024 points
203+
T = tau/n # sampling interval
204+
t = np.arange(n)*T
205+
206+
a = 4 # amplitude
207+
x = a*np.sin(40*np.pi*t) # 20 Hz sine with amplitude a
208+
209+
# New correct behavior: Amplitude at 20 Hz is a/2
210+
plt.magnitude_spectrum(x, Fs=1/T, sides='onesided', scale='linear')
211+
212+
# Original behavior: Amplitude at 20 Hz is (a/2)*(n/2) for a Hanning window
213+
w = np.hanning(n) # default window is a Hanning window
214+
plt.magnitude_spectrum(x*np.sum(w), Fs=1/T, sides='onesided', scale='linear')
215+
216+
217+
218+
Default behavior of log scales changed to mask <= 0 values
219+
----------------------------------------------------------
220+
221+
Calling `matplotlib.axes.Axes.set_xscale` or `matplotlib.axes.Axes.set_yscale`
222+
now uses 'mask' as the default method to handle invalid values (as opposed to
223+
'clip'). This means that any values <= 0 on a log scale will not be shown.
224+
225+
Previously they were clipped to a very small number and shown.
226+
227+
228+
Code Removal
229+
------------
230+
231+
matplotlib.delaunay
232+
~~~~~~~~~~~~~~~~~~~
233+
Remove the delaunay triangulation code which is now handled by Qhull
234+
via ``matplotlib.tri``
235+
236+
237+
qt4_compat.py
238+
~~~~~~~~~~~~~
239+
Moved to ``qt_compat.py``. Renamed because it now handles Qt5 as well.
240+
241+
242+
Deprecated methods
243+
~~~~~~~~~~~~~~~~~~
244+
245+
The ``GraphicsContextBase.set_graylevel``, ``FigureCanvasBase.onHilite`` and
246+
``mpl_toolkits.axes_grid1.mpl_axes.Axes.toggle_axisline`` methods have been
247+
removed.
248+
249+
The ``ArtistInspector.findobj`` method, which was never working due to the lack
250+
of a ``get_children`` method, has been removed.
251+
252+
The deprecated ``point_in_path``, ``get_path_extents``,
253+
``point_in_path_collection``, ``path_intersects_path``,
254+
``convert_path_to_polygons``, ``cleanup_path`` and ``clip_path_to_rect``
255+
functions in the ``matplotlib.path`` module have been removed. Their
256+
functionality remains exposed as methods on the ``Path`` class.
257+
258+
259+
`Axes.set_aspect("normal")`
260+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
261+
262+
Support for setting an ``Axes``' aspect to ``"normal"`` has been removed, in
263+
favor of the synonym ``"auto"``.
264+
265+
266+
``shading`` kwarg to ``pcolor``
267+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
268+
269+
The ``shading`` kwarg to ``pcolor`` has been removed. Set ``edgecolors``
270+
appropriately instead.
271+
272+
273+
Removed internal functions
274+
~~~~~~~~~~~~~~~~~~~~~~~~~~
275+
276+
The ``matplotlib.backends.backend_ps.seq_allequal`` function has been removed.
277+
Use ``np.array_equal`` instead.
278+
279+
The deprecated ``matplotlib.rcsetup.validate_maskedarray``,
280+
``matplotlib.rcsetup.deprecate_savefig_extension`` and
281+
``matplotlib.rcsetup.validate_tkpythoninspect`` functions, and associated
282+
``savefig.extension`` and ``tk.pythoninspect`` rcparams entries have been
283+
removed.
284+
285+
286+
Deprecations
287+
------------
288+
289+
- `matplotlib.testing.noseclasses` is deprecated and will be removed in 2.3
290+
291+
292+
Functions removed from the `lines` module
293+
-----------------------------------------
294+
295+
The `matplotlib.lines` module no longer imports the `pts_to_prestep`,
296+
`pts_to_midstep` and `pts_to_poststep` functions from the `matplotlib.cbook`
297+
module.
298+
299+
13300
API Changes in 2.0.1
14301
====================
15302

doc/api/api_changes/2015-12-30-JHN.rst

-7
This file was deleted.

doc/api/api_changes/2016-08-02-toggle-grids.rst

-9
This file was deleted.

doc/api/api_changes/2016-09-28-AL_emptylegend.rst

-5
This file was deleted.

doc/api/api_changes/2016-12-14-AL_legend-autoposition.rst

-4
This file was deleted.

doc/api/api_changes/2016-12-19-ESDA_sample_data.rst

-13
This file was deleted.

doc/api/api_changes/2017-01-06-IT.rst

-6
This file was deleted.

doc/api/api_changes/2017-01-19-BFLC.rst

-4
This file was deleted.

doc/api/api_changes/2017-01-30-AL_is_numlike_stringlike.rst

-10
This file was deleted.

doc/api/api_changes/2017-02-10-DS_elliptical_arc_angle.rst

-8
This file was deleted.

doc/api/api_changes/2017-02-12-JKS.rst

-8
This file was deleted.

doc/api/api_changes/2017-02-25-AL_dbackend.rst

-4
This file was deleted.

0 commit comments

Comments
 (0)