File: deprecations.rst

package info (click to toggle)
matplotlib 3.10.1%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 78,352 kB
  • sloc: python: 147,118; cpp: 62,988; objc: 1,679; ansic: 1,426; javascript: 786; makefile: 104; sh: 53
file content (348 lines) | stat: -rw-r--r-- 13,755 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
Deprecations
------------

Extra parameters to Axes constructor
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Parameters of the Axes constructor other than *fig* and *rect* will become
keyword-only in a future version.

``pyplot.gca`` and ``Figure.gca`` keyword arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing keyword arguments to `.pyplot.gca` or `.figure.Figure.gca` will not be
supported in a future release.

``Axis.cla``, ``RadialAxis.cla``, ``ThetaAxis.cla`` and ``Spine.cla``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These methods are deprecated in favor of the respective ``clear()`` methods.

Invalid hatch pattern characters are no longer ignored
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When specifying hatching patterns, characters that are not recognized will
raise a deprecation warning. In the future, this will become a hard error.

``imread`` reading from URLs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing a URL to `~.pyplot.imread()` is deprecated. Please open the URL for
reading and directly use the Pillow API
(``PIL.Image.open(urllib.request.urlopen(url))``, or
``PIL.Image.open(io.BytesIO(requests.get(url).content))``) instead.

Subplot-related attributes and methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Some ``SubplotBase`` methods and attributes have been deprecated and/or moved
to `.SubplotSpec`:

- ``get_geometry`` (use ``SubplotBase.get_subplotspec`` instead),
- ``change_geometry`` (use ``SubplotBase.set_subplotspec`` instead),
- ``is_first_row``, ``is_last_row``, ``is_first_col``, ``is_last_col`` (use the
  corresponding methods on the `.SubplotSpec` instance instead),
- ``update_params`` (now a no-op),
- ``figbox`` (use ``ax.get_subplotspec().get_geometry(ax.figure)`` instead to
  recompute the geometry, or ``ax.get_position()`` to read its current value),
- ``numRows``, ``numCols`` (use the ``nrows`` and ``ncols`` attribute on the
  `.GridSpec` instead).

Likewise, the ``get_geometry``, ``change_geometry``, ``update_params``, and
``figbox`` methods/attributes of `.SubplotDivider` have been deprecated, with
similar replacements.

``is_url`` and ``URL_REGEX``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... are deprecated. (They were previously defined in the toplevel
:mod:`matplotlib` module.)

``matplotlib.style.core`` deprecations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``STYLE_FILE_PATTERN``, ``load_base_library``, and ``iter_user_libraries`` are
deprecated.

``dpi_cor`` property of `.FancyArrowPatch`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This parameter is considered internal and deprecated.

Passing ``boxstyle="custom", bbox_transmuter=...`` to ``FancyBboxPatch``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In order to use a custom boxstyle, directly pass it as the *boxstyle* argument
to `.FancyBboxPatch`. This was previously already possible, and is consistent
with custom arrow styles and connection styles.

BoxStyles are now called without passing the *mutation_aspect* parameter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Mutation aspect is now handled by the artist itself. Hence the
*mutation_aspect* parameter of ``BoxStyle._Base.__call__`` is deprecated, and
custom boxstyles should be implemented to not require this parameter (it can be
left as a parameter defaulting to 1 for back-compatibility).

``ContourLabeler.get_label_coords`` is deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is considered an internal helper.

Line2D and Patch no longer duplicate ``validJoin`` and ``validCap``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Validation of joinstyle and capstyles is now centralized in ``rcsetup``.

Setting a Line2D's pickradius via ``set_picker`` is undeprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This cancels the deprecation introduced in Matplotlib 3.3.0.

``MarkerStyle`` is considered immutable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``MarkerStyle.set_fillstyle()`` and ``MarkerStyle.set_marker()`` are
deprecated. Create a new ``MarkerStyle`` with the respective parameters
instead.

``MovieWriter.cleanup`` is deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cleanup logic is now fully implemented in `.MovieWriter.finish`. Third-party
movie writers should likewise move the relevant cleanup logic there, as
overridden ``cleanup``\s will no longer be called in the future.

*minimumdescent* parameter/property of ``TextArea``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

`.offsetbox.TextArea` has behaved as if *minimumdescent* was always True
(regardless of the value to which it was set) since Matplotlib 1.3, so the
parameter/property is deprecated.

``colorbar`` now warns when the mappable's Axes is different from the current Axes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Currently, `.Figure.colorbar` and `.pyplot.colorbar` steal space by default
from the current Axes to place the colorbar. In a future version, they will
steal space from the mappable's Axes instead. In preparation for this change,
`.Figure.colorbar` and `.pyplot.colorbar` now emits a warning when the current
Axes is not the same as the mappable's Axes.

Colorbar docstrings
~~~~~~~~~~~~~~~~~~~

The following globals in :mod:`matplotlib.colorbar` are deprecated:
``colorbar_doc``, ``colormap_kw_doc``, ``make_axes_kw_doc``.

``ColorbarPatch`` and ``colorbar_factory`` are deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All the relevant functionality has been moved to the
`~matplotlib.colorbar.Colorbar` class.

Backend deprecations
~~~~~~~~~~~~~~~~~~~~

- ``FigureCanvasBase.get_window_title`` and
  ``FigureCanvasBase.set_window_title`` are deprecated. Use the corresponding
  methods on the FigureManager if using pyplot, or GUI-specific methods if
  embedding.
- The *resize_callback* parameter to ``FigureCanvasTk`` was never used
  internally and is deprecated. Tk-level custom event handlers for resize
  events can be added to a ``FigureCanvasTk`` using e.g.
  ``get_tk_widget().bind('<Configure>', ..., True)``.
- The ``key_press`` and ``button_press`` methods of `.FigureManagerBase`, which
  incorrectly did nothing when using ``toolmanager``, are deprecated in favor
  of directly passing the event to the `.CallbackRegistry` via
  ``self.canvas.callbacks.process(event.name, event)``.
- ``RendererAgg.get_content_extents`` and
  ``RendererAgg.tostring_rgba_minimized`` are deprecated.
- ``backend_pgf.TmpDirCleaner`` is deprecated, with no replacement.
- ``GraphicsContextPS`` is deprecated. The PostScript backend now uses
  `.GraphicsContextBase`.

wx backend cleanups
~~~~~~~~~~~~~~~~~~~

The *origin* parameter to ``_FigureCanvasWxBase.gui_repaint`` is deprecated
with no replacement; ``gui_repaint`` now automatically detects the case where
it is used with the wx renderer.

The ``NavigationToolbar2Wx.get_canvas`` method is deprecated; directly
instantiate a canvas (``FigureCanvasWxAgg(frame, -1, figure)``) if needed.

Unused positional parameters to ``print_<fmt>`` methods are deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

None of the ``print_<fmt>`` methods implemented by canvas subclasses used
positional arguments other that the first (the output filename or file-like),
so these extra parameters are deprecated.

The *dpi* parameter of ``FigureCanvas.print_foo`` printers is deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The `~.Figure.savefig` machinery already took care of setting the figure DPI
to the desired value, so ``print_foo`` can directly read it from there. Not
passing *dpi* to ``print_foo`` allows clearer detection of unused parameters
passed to `~.Figure.savefig`.

Passing `bytes` to ``FT2Font.set_text``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is deprecated, pass `str` instead.

``ps.useafm`` deprecated for mathtext
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Outputting mathtext using only standard PostScript fonts has likely been broken
for a while (issue `#18722
<https://github.com/matplotlib/matplotlib/issues/18722>`_). In Matplotlib 3.5,
the setting :rc:`ps.useafm` will have no effect on mathtext.

``MathTextParser("bitmap")`` is deprecated
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The associated APIs ``MathtextBackendBitmap``, ``MathTextParser.to_mask``,
``MathTextParser.to_rgba``, ``MathTextParser.to_png``, and
``MathTextParser.get_depth`` are likewise deprecated.

To convert a text string to an image, either directly draw the text to an
empty `.Figure` and save the figure using a tight bbox, as demonstrated in
:doc:`/gallery/text_labels_and_annotations/mathtext_asarray`, or use
`.mathtext.math_to_image`.

When using `.math_to_image`, text color can be set with e.g.::

    with plt.rc_context({"text.color": "tab:blue"}):
        mathtext.math_to_image(text, filename)

and an RGBA array can be obtained with e.g.::

    from io import BytesIO
    buf = BytesIO()
    mathtext.math_to_image(text, buf, format="png")
    buf.seek(0)
    rgba = plt.imread(buf)

Deprecation of mathtext internals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following API elements previously exposed by the :mod:`.mathtext` module
are considered to be implementation details and public access to them is
deprecated:

- ``Fonts`` and all its subclasses,
- ``FontConstantsBase`` and all its subclasses,
- ``Node`` and all its subclasses,
- ``Ship``, ``ship``,
- ``Error``,
- ``Parser``,
- ``SHRINK_FACTOR``, ``GROW_FACTOR``,
- ``NUM_SIZE_LEVELS``,
- ``latex_to_bakoma``, ``latex_to_cmex``, ``latex_to_standard``,
- ``stix_virtual_fonts``,
- ``tex2uni``.

Deprecation of various mathtext helpers
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``MathtextBackendPdf``, ``MathtextBackendPs``, ``MathtextBackendSvg``,
and ``MathtextBackendCairo`` classes from the :mod:`.mathtext` module, as
well as the corresponding ``.mathtext_parser`` attributes on ``RendererPdf``,
``RendererPS``, ``RendererSVG``, and ``RendererCairo``, are deprecated. The
``MathtextBackendPath`` class can be used to obtain a list of glyphs and
rectangles in a mathtext expression, and renderer-specific logic should be
directly implemented in the renderer.

``StandardPsFonts.pswriter`` is unused and deprecated.

Widget class internals
~~~~~~~~~~~~~~~~~~~~~~

Several `.widgets.Widget` class internals have been privatized and deprecated:

- ``AxesWidget.cids``
- ``Button.cnt`` and ``Button.observers``
- ``CheckButtons.cnt`` and ``CheckButtons.observers``
- ``RadioButtons.cnt`` and ``RadioButtons.observers``
- ``Slider.cnt`` and ``Slider.observers``
- ``TextBox.cnt``, ``TextBox.change_observers`` and
  ``TextBox.submit_observers``

3D properties on renderers
~~~~~~~~~~~~~~~~~~~~~~~~~~

The properties of the 3D Axes that were placed on the Renderer during draw are
now deprecated:

- ``renderer.M``
- ``renderer.eye``
- ``renderer.vvec``
- ``renderer.get_axis_position``

These attributes are all available via `.Axes3D`, which can be accessed via
``self.axes`` on all `.Artist`\s.

*renderer* argument of ``do_3d_projection`` method for ``Collection3D``/``Patch3D``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *renderer* argument for the ``do_3d_projection`` method on ``Collection3D``
and ``Patch3D`` is no longer necessary, and passing it during draw is
deprecated.

*project* argument of ``draw`` method for ``Line3DCollection``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The *project* argument for the ``draw`` method on ``Line3DCollection`` is
deprecated. Call `.Line3DCollection.do_3d_projection` explicitly instead.

Extra positional parameters to ``plot_surface`` and ``plot_wireframe``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Positional parameters to `~.axes3d.Axes3D.plot_surface` and
`~.axes3d.Axes3D.plot_wireframe` other than ``X``, ``Y``, and ``Z`` are
deprecated. Pass additional artist properties as keyword arguments instead.

``ParasiteAxesAuxTransBase`` class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The functionality of that mixin class has been moved to the base
``ParasiteAxesBase`` class. Thus, ``ParasiteAxesAuxTransBase``,
``ParasiteAxesAuxTrans``, and ``parasite_axes_auxtrans_class_factory`` are
deprecated.

In general, it is suggested to use ``HostAxes.get_aux_axes`` to create
parasite Axes, as this saves the need of manually appending the parasite
to ``host.parasites`` and makes sure that their ``remove()`` method works
properly.

``AxisArtist.ZORDER`` attribute
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Use ``AxisArtist.zorder`` instead.

``GridHelperBase`` invalidation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The ``GridHelperBase.invalidate``, ``GridHelperBase.valid``, and
``axislines.Axes.invalidate_grid_helper`` methods are considered internal
and deprecated.

``sphinext.plot_directive.align``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

... is deprecated. Use ``docutils.parsers.rst.directives.images.Image.align``
instead.

Deprecation-related functionality is considered internal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The module ``matplotlib.cbook.deprecation`` is considered internal and will be
removed from the public API. This also holds for deprecation-related re-imports
in ``matplotlib.cbook``, i.e. ``matplotlib.cbook.deprecated()``,
``matplotlib.cbook.warn_deprecated()``,
``matplotlib.cbook.MatplotlibDeprecationWarning`` and
``matplotlib.cbook.mplDeprecation``.

If needed, external users may import ``MatplotlibDeprecationWarning`` directly
from the ``matplotlib`` namespace. ``mplDeprecation`` is only an alias of
``MatplotlibDeprecationWarning`` and should not be used anymore.