1
2
3API Changes in 2.1.0
4====================
5
6
7Default behavior of log scales changed to mask <= 0 values
8----------------------------------------------------------
9
10Calling `matplotlib.axes.Axes.set_xscale` or `matplotlib.axes.Axes.set_yscale`
11now uses 'mask' as the default method to handle invalid values (as opposed to
12'clip'). This means that any values <= 0 on a log scale will not be shown.
13
14Previously they were clipped to a very small number and shown.
15
16
17:meth:`matplotlib.cbook.CallbackRegistry.process` suppresses exceptions by default
18----------------------------------------------------------------------------------
19
20Matplotlib uses instances of :obj:`~matplotlib.cbook.CallbackRegistry`
21as a bridge between user input event from the GUI and user callbacks.
22Previously, any exceptions raised in a user call back would bubble out
23of of the ``process`` method, which is typically in the GUI event
24loop.  Most GUI frameworks simple print the traceback to the screen
25and continue as there is not always a clear method of getting the
26exception back to the user.  However PyQt5 now exits the process when
27it receives an un-handled python exception in the event loop.  Thus,
28:meth:`~matplotlib.cbook.CallbackRegistry.process` now suppresses and
29prints tracebacks to stderr by default.
30
31What :meth:`~matplotlib.cbook.CallbackRegistry.process` does with exceptions
32is now user configurable via the ``exception_handler`` attribute and kwarg.  To
33restore the previous behavior pass ``None`` ::
34
35  cb = CallbackRegistry(exception_handler=None)
36
37
38A function which take and ``Exception`` as its only argument may also be passed ::
39
40  def maybe_reraise(exc):
41      if isinstance(exc, RuntimeError):
42          pass
43      else:
44          raise exc
45
46  cb = CallbackRegistry(exception_handler=maybe_reraise)
47
48
49
50Improved toggling of the axes grids
51-----------------------------------
52
53The ``g`` key binding now switches the states of the ``x`` and ``y`` grids
54independently (by cycling through all four on/off combinations).
55
56The new ``G`` key binding switches the states of the minor grids.
57
58Both bindings are disabled if only a subset of the grid lines (in either
59direction) is visible, to avoid making irreversible changes to the figure.
60
61
62Ticklabels are turned off instead of being invisible
63----------------------------------------------------
64
65Internally, the `.Tick`'s ``~matplotlib.axis.Tick.label1On`` attribute
66is now used to hide tick labels instead of setting the visibility on the tick
67label objects.
68This improves overall performance and fixes some issues.
69As a consequence, in case those labels ought to be shown,
70:func:`~matplotlib.axes.Axes.tick_params`
71needs to be used, e.g.
72
73::
74
75    ax.tick_params(labelbottom=True)
76
77
78Removal of warning on empty legends
79-----------------------------------
80
81`.pyplot.legend` used to issue a warning when no labeled artist could be
82found.  This warning has been removed.
83
84
85More accurate legend autopositioning
86------------------------------------
87
88Automatic positioning of legends now prefers using the area surrounded
89by a `.Line2D` rather than placing the legend over the line itself.
90
91
92Cleanup of stock sample data
93----------------------------
94
95The sample data of stocks has been cleaned up to remove redundancies and
96increase portability. The ``AAPL.dat.gz``, ``INTC.dat.gz`` and ``aapl.csv``
97files have been removed entirely and will also no longer be available from
98`matplotlib.cbook.get_sample_data`. If a CSV file is required, we suggest using
99the ``msft.csv`` that continues to be shipped in the sample data. If a NumPy
100binary file is acceptable, we suggest using one of the following two new files.
101The ``aapl.npy.gz`` and ``goog.npy`` files have been replaced by ``aapl.npz``
102and ``goog.npz``, wherein the first column's type has changed from
103`datetime.date` to `numpy.datetime64` for better portability across Python
104versions. Note that Matplotlib does not fully support `numpy.datetime64` as
105yet.
106
107
108Updated qhull to 2015.2
109-----------------------
110
111The version of qhull shipped with Matplotlib, which is used for
112Delaunay triangulation, has been updated from version 2012.1 to
1132015.2.
114
115Improved Delaunay triangulations with large offsets
116---------------------------------------------------
117
118Delaunay triangulations now deal with large x,y offsets in a better
119way. This can cause minor changes to any triangulations calculated
120using Matplotlib, i.e. any use of `matplotlib.tri.Triangulation` that
121requests that a Delaunay triangulation is calculated, which includes
122`matplotlib.pyplot.tricontour`, `matplotlib.pyplot.tricontourf`,
123`matplotlib.pyplot.tripcolor`, `matplotlib.pyplot.triplot`,
124``matplotlib.mlab.griddata`` and
125`mpl_toolkits.mplot3d.axes3d.Axes3D.plot_trisurf`.
126
127
128
129Use ``backports.functools_lru_cache`` instead of ``functools32``
130----------------------------------------------------------------
131
132It's better maintained and more widely used (by pylint, jaraco, etc).
133
134
135
136``cbook.is_numlike`` only performs an instance check
137----------------------------------------------------
138
139``matplotlib.cbook.is_numlike`` now only checks that its argument
140is an instance of ``(numbers.Number, np.Number)``.  In particular,
141this means that arrays are now not num-like.
142
143
144
145Elliptical arcs now drawn between correct angles
146------------------------------------------------
147
148The `matplotlib.patches.Arc` patch is now correctly drawn between the given
149angles.
150
151Previously a circular arc was drawn and then stretched into an ellipse,
152so the resulting arc did not lie between *theta1* and *theta2*.
153
154
155
156``-d$backend`` no longer sets the backend
157-----------------------------------------
158
159It is no longer possible to set the backend by passing ``-d$backend``
160at the command line.  Use the ``MPLBACKEND`` environment variable
161instead.
162
163
164Path.intersects_bbox always treats the bounding box as filled
165-------------------------------------------------------------
166
167Previously, when ``Path.intersects_bbox`` was called with ``filled`` set to
168``False``, it would treat both the path and the bounding box as unfilled. This
169behavior was not well documented and it is usually not the desired behavior,
170since bounding boxes are used to represent more complex shapes located inside
171the bounding box. This behavior has now been changed: when ``filled`` is
172``False``, the path will be treated as unfilled, but the bounding box is still
173treated as filled. The old behavior was arguably an implementation bug.
174
175When ``Path.intersects_bbox`` is called with ``filled`` set to ``True``
176(the default value), there is no change in behavior. For those rare cases where
177``Path.intersects_bbox`` was called with ``filled`` set to ``False`` and where
178the old behavior is actually desired, the suggested workaround is to call
179``Path.intersects_path`` with a rectangle as the path::
180
181    from matplotlib.path import Path
182    from matplotlib.transforms import Bbox, BboxTransformTo
183    rect = Path.unit_rectangle().transformed(BboxTransformTo(bbox))
184    result = path.intersects_path(rect, filled=False)
185
186
187
188
189WX no longer calls generates ``IdleEvent`` events or calls ``idle_event``
190-------------------------------------------------------------------------
191
192Removed unused private method ``_onIdle`` from ``FigureCanvasWx``.
193
194The ``IdleEvent`` class and ``FigureCanvasBase.idle_event`` method
195will be removed in 2.2
196
197
198
199Correct scaling of ``magnitude_spectrum()``
200-------------------------------------------
201
202The functions :func:`matplotlib.mlab.magnitude_spectrum()` and :func:`matplotlib.pyplot.magnitude_spectrum()` implicitly assumed the sum
203of windowing function values to be one. In Matplotlib and Numpy the
204standard windowing functions are scaled to have maximum value of one,
205which usually results in a sum of the order of n/2 for a n-point
206signal. Thus the amplitude scaling ``magnitude_spectrum()`` was
207off by that amount when using standard windowing functions (`Bug 8417
208<https://github.com/matplotlib/matplotlib/issues/8417>`_ ). Now the
209behavior is consistent with :func:`matplotlib.pyplot.psd()` and
210:func:`scipy.signal.welch()`. The following example demonstrates the
211new and old scaling::
212
213    import matplotlib.pyplot as plt
214    import numpy as np
215
216    tau, n = 10, 1024  # 10 second signal with 1024 points
217    T = tau/n  # sampling interval
218    t = np.arange(n)*T
219
220    a = 4  # amplitude
221    x = a*np.sin(40*np.pi*t)  # 20 Hz sine with amplitude a
222
223    # New correct behavior: Amplitude at 20 Hz is a/2
224    plt.magnitude_spectrum(x, Fs=1/T, sides='onesided', scale='linear')
225
226    # Original behavior: Amplitude at 20 Hz is (a/2)*(n/2) for a Hanning window
227    w = np.hanning(n)  # default window is a Hanning window
228    plt.magnitude_spectrum(x*np.sum(w), Fs=1/T, sides='onesided', scale='linear')
229
230
231
232
233
234Change to signatures of :meth:`~matplotlib.axes.Axes.bar` & :meth:`~matplotlib.axes.Axes.barh`
235----------------------------------------------------------------------------------------------
236
237For 2.0 the :ref:`default value of *align* <barbarh_align>` changed to
238``'center'``.  However this caused the signature of
239:meth:`~matplotlib.axes.Axes.bar` and
240:meth:`~matplotlib.axes.Axes.barh` to be misleading as the first parameters were
241still *left* and *bottom* respectively::
242
243  bar(left, height, *, align='center', **kwargs)
244  barh(bottom, width, *, align='center', **kwargs)
245
246despite behaving as the center in both cases. The methods now take
247``*args, **kwargs`` as input and are documented to have the primary
248signatures of::
249
250  bar(x, height, *, align='center', **kwargs)
251  barh(y, width, *, align='center', **kwargs)
252
253Passing *left* and *bottom* as keyword arguments to
254:meth:`~matplotlib.axes.Axes.bar` and
255:meth:`~matplotlib.axes.Axes.barh` respectively will warn.
256Support will be removed in Matplotlib 3.0.
257
258
259Font cache as json
260------------------
261
262The font cache is now saved as json, rather than a pickle.
263
264
265Invalid (Non-finite) Axis Limit Error
266-------------------------------------
267
268When using :func:`~matplotlib.axes.Axes.set_xlim` and
269:func:`~matplotlib.axes.Axes.set_ylim`, passing non-finite values now
270results in a ``ValueError``. The previous behavior resulted in the
271limits being erroneously reset to ``(-0.001, 0.001)``.
272
273``scatter`` and ``Collection`` offsets are no longer implicitly flattened
274-------------------------------------------------------------------------
275
276`~matplotlib.collections.Collection` (and thus both 2D
277`~matplotlib.axes.Axes.scatter` and 3D
278`~mpl_toolkits.mplot3d.axes3d.Axes3D.scatter`) no
279longer implicitly flattens its offsets.  As a consequence, ``scatter``'s ``x``
280and ``y`` arguments can no longer be 2+-dimensional arrays.
281
282Deprecations
283------------
284
285``GraphicsContextBase``\'s ``linestyle`` property.
286~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287
288The ``GraphicsContextBase.get_linestyle`` and
289``GraphicsContextBase.set_linestyle`` methods, which had no effect,
290have been deprecated.  All of the backends Matplotlib ships use
291``GraphicsContextBase.get_dashes`` and
292``GraphicsContextBase.set_dashes`` which are more general.
293Third-party backends should also migrate to the ``*_dashes`` methods.
294
295
296``NavigationToolbar2.dynamic_update``
297~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
298
299Use :meth:`.draw_idle` method on the ``Canvas`` instance instead.
300
301
302Testing
303~~~~~~~
304
305``matplotlib.testing.noseclasses`` is deprecated and will be removed in 2.3
306
307
308``EngFormatter`` *num* arg as string
309~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
310
311Passing a string as *num* argument when calling an instance of
312`matplotlib.ticker.EngFormatter` is deprecated and will be removed in 2.3.
313
314
315``mpl_toolkits.axes_grid`` module
316~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317
318All functionally from ``mpl_toolkits.axes_grid`` can be found in either
319`mpl_toolkits.axes_grid1` or `mpl_toolkits.axisartist`. Axes classes
320from ``mpl_toolkits.axes_grid`` based on ``Axis`` from
321`mpl_toolkits.axisartist` can be found in `mpl_toolkits.axisartist`.
322
323
324``Axes`` collision in ``Figure.add_axes``
325~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
326
327Adding an axes instance to a figure by using the same arguments as for
328a previous axes instance currently reuses the earlier instance.  This
329behavior has been deprecated in Matplotlib 2.1. In a future version, a
330*new* instance will always be created and returned.  Meanwhile, in such
331a situation, a deprecation warning is raised by
332``matplotlib.figure.AxesStack``.
333
334This warning can be suppressed, and the future behavior ensured, by passing
335a *unique* label to each axes instance.  See the docstring of
336:meth:`~matplotlib.figure.Figure.add_axes` for more information.
337
338Additional details on the rationale behind this deprecation can be found
339in :ghissue:`7377` and :ghissue:`9024`.
340
341
342Former validators for ``contour.negative_linestyle``
343~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
344
345
346The former public validation functions ``validate_negative_linestyle``
347and ``validate_negative_linestyle_legacy`` will be deprecated in 2.1 and
348may be removed in 2.3. There are no public functions to replace them.
349
350
351
352``cbook``
353~~~~~~~~~
354
355Many unused or near-unused :mod:`matplotlib.cbook` functions and
356classes have been deprecated: ``converter``, ``tostr``,
357``todatetime``, ``todate``, ``tofloat``, ``toint``, ``unique``,
358``is_string_like``, ``is_sequence_of_strings``, ``is_scalar``,
359``Sorter``, ``Xlator``, ``soundex``, ``Null``, ``dict_delall``,
360``RingBuffer``, ``get_split_ind``, ``wrap``,
361``get_recursive_filelist``, ``pieces``, ``exception_to_str``,
362``allequal``, ``alltrue``, ``onetrue``, ``allpairs``, ``finddir``,
363``reverse_dict``, ``restrict_dict``, ``issubclass_safe``,
364``recursive_remove``, ``unmasked_index_ranges``.
365
366
367Code Removal
368------------
369
370qt4_compat.py
371~~~~~~~~~~~~~
372
373Moved to ``qt_compat.py``.  Renamed because it now handles Qt5 as well.
374
375
376Previously Deprecated methods
377~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
378
379The ``GraphicsContextBase.set_graylevel``, ``FigureCanvasBase.onHilite`` and
380``mpl_toolkits.axes_grid1.mpl_axes.Axes.toggle_axisline`` methods have been
381removed.
382
383The ``ArtistInspector.findobj`` method, which was never working due to the lack
384of a ``get_children`` method, has been removed.
385
386The deprecated ``point_in_path``, ``get_path_extents``,
387``point_in_path_collection``, ``path_intersects_path``,
388``convert_path_to_polygons``, ``cleanup_path`` and ``clip_path_to_rect``
389functions in the ``matplotlib.path`` module have been removed.  Their
390functionality remains exposed as methods on the ``Path`` class.
391
392The deprecated ``Artist.get_axes`` and ``Artist.set_axes`` methods
393have been removed
394
395
396The ``matplotlib.backends.backend_ps.seq_allequal`` function has been removed.
397Use ``np.array_equal`` instead.
398
399The deprecated ``matplotlib.rcsetup.validate_maskedarray``,
400``matplotlib.rcsetup.deprecate_savefig_extension`` and
401``matplotlib.rcsetup.validate_tkpythoninspect`` functions, and associated
402``savefig.extension`` and ``tk.pythoninspect`` rcparams entries have been
403removed.
404
405
406The keyword argument *resolution* of
407:class:`matplotlib.projections.polar.PolarAxes` has been removed. It
408has deprecation with no effect from version *0.98.x*.
409
410
411``Axes.set_aspect("normal")``
412~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
413
414Support for setting an ``Axes``\'s aspect to ``"normal"`` has been
415removed, in favor of the synonym ``"auto"``.
416
417
418``shading`` kwarg to ``pcolor``
419~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
420
421The ``shading`` kwarg to `~matplotlib.axes.Axes.pcolor` has been
422removed.  Set ``edgecolors`` appropriately instead.
423
424
425Functions removed from the `.lines` module
426~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
427
428The :mod:`matplotlib.lines` module no longer imports the
429``pts_to_prestep``, ``pts_to_midstep`` and ``pts_to_poststep``
430functions from :mod:`matplotlib.cbook`.
431
432
433PDF backend functions
434~~~~~~~~~~~~~~~~~~~~~
435
436The methods ``embedTeXFont`` and ``tex_font_mapping`` of
437:class:`matplotlib.backends.backend_pdf.PdfFile` have been removed.  It is
438unlikely that external users would have called these methods, which
439are related to the font system internal to the PDF backend.
440
441
442matplotlib.delaunay
443~~~~~~~~~~~~~~~~~~~
444
445Remove the delaunay triangulation code which is now handled by Qhull
446via :mod:`matplotlib.tri`.
447