1
- .. _whats= new :
1
+ .. _whats- new :
2
2
3
- =============================
3
+ ==============================
4
4
What's new in Matplotlib 3.1
5
- =============================
5
+ ==============================
6
6
7
7
For a list of all of the issues and pull requests since the last
8
8
revision, see the :ref: `github-stats `.
@@ -14,10 +14,11 @@ revision, see the :ref:`github-stats`.
14
14
:maxdepth: 4
15
15
16
16
New Features
17
- =============
17
+ ============
18
18
19
19
`~.dates.ConciseDateFormatter `
20
- -------------------------------
20
+ ------------------------------
21
+
21
22
The automatic date formatter used by default can be quite verbose. A new
22
23
formatter can be accessed that tries to make the tick labels appropriately
23
24
concise.
@@ -55,7 +56,8 @@ concise.
55
56
plt.show()
56
57
57
58
Secondary x/y Axis support
58
- ------------------------------------------------------------
59
+ --------------------------
60
+
59
61
A new method provides the ability to add a second axis to an existing
60
62
axes via `.Axes.secondary_xaxis ` and `.Axes.secondary_yaxis `. See
61
63
:doc: `/gallery/subplots_axes_and_figures/secondary_axis ` for examples.
@@ -70,45 +72,53 @@ axes via `.Axes.secondary_xaxis` and `.Axes.secondary_yaxis`. See
70
72
71
73
72
74
`~.scale.FuncScale ` for arbitrary axes scales
73
- ----------------------------------------------
75
+ ---------------------------------------------
76
+
74
77
A new `-.scale.FuncScale ` class was added (and `-.scale.FuncTransform `)
75
78
to allow the user to have arbitrary scale transformations without having to
76
- write a new subclass of `-.scale.ScaleBase `. This can be accessed by
77
- ``ax.set_yscale('function', functions=(forward, inverse)) ``, where
78
- ``forward `` and ``inverse `` are callables that return the scale transform and
79
- its inverse. See the last example in :doc: `/gallery/scales/scales `.
79
+ write a new subclass of `-.scale.ScaleBase `. This can be accessed by::
80
+
81
+ ax.set_yscale('function', functions=(forward, inverse))
82
+
83
+ where ``forward `` and ``inverse `` are callables that return the scale
84
+ transform and its inverse. See the last example in
85
+ :doc: `/gallery/scales/scales `.
80
86
81
87
82
88
Legend for scatter
83
- -------------------
84
- A new method for creating legends for scatter plots has been introduced.
85
- Previously, in order to obtain a legend for a :meth: `-.axes.Axes.scatter `
86
- plot, one could either plot several scatters, each with an individual label,
87
- or create proxy artists to show in the legend manually.
88
- Now, :class: `-.collections.PathCollection ` provides a method
89
- :meth: `-.collections.PathCollection.legend_elements ` to obtain the handles and labels
90
- for a scatter plot in an automated way. This makes creating a legend for a
91
- scatter plot as easy as::
89
+ ------------------
90
+
91
+ A new method for creating legends for scatter plots has been
92
+ introduced. Previously, in order to obtain a legend for a
93
+ :meth: `-.axes.Axes.scatter ` plot, one could either plot several
94
+ scatters, each with an individual label, or create proxy artists to
95
+ show in the legend manually. Now,
96
+ :class: `-.collections.PathCollection ` provides a method
97
+ :meth: `-.collections.PathCollection.legend_elements ` to obtain the
98
+ handles and labels for a scatter plot in an automated way. This makes
99
+ creating a legend for a scatter plot as easy as
100
+
101
+ .. plot ::
92
102
93
103
scatter = plt.scatter([1,2,3], [4,5,6], c=[7,2,3])
94
104
plt.legend(*scatter.legend_elements())
95
105
96
- An example can be found in
97
- :ref: `automatedlegendcreation `.
106
+ An example can be found in :ref: `automatedlegendcreation `.
98
107
99
108
100
109
Figure, FigureCanvas, and Backends
101
- ====================================
110
+ ==================================
102
111
103
112
Figure.frameon is now a direct proxy for the Figure patch visibility state
104
- ---------------------------------------------------------------------------
113
+ --------------------------------------------------------------------------
105
114
Accessing ``Figure.frameon `` (including via ``get_frameon `` and ``set_frameon ``
106
115
now directly forwards to the visibility of the underlying Rectangle artist
107
116
(``Figure.patch.get_frameon ``, ``Figure.patch.set_frameon ``).
108
117
109
118
110
119
*pil_kwargs * argument added to savefig
111
- ------------------------------------------------------------
120
+ --------------------------------------
121
+
112
122
Matplotlib uses Pillow to handle saving to the JPEG and TIFF formats. The
113
123
`-Figure.savefig() ` function gained a *pil_kwargs * keyword argument, which can
114
124
be used to forward arguments to Pillow's `PIL.Image.save() `.
@@ -118,38 +128,44 @@ Matplotlib also uses Pillow's `PIL.Image.save()` instead of going through its
118
128
own builtin PNG support.
119
129
120
130
121
- Add ``inaxes `` method to `FigureCanvas `
122
- ----------------------------------------
123
- The `FigureCanvas ` class has now an ``inaxes `` method to check whether a point is in an axes
124
- and returns the topmost axes, else None.
131
+ Add ``inaxes `` method to `.FigureCanvasBase `
132
+ --------------------------------------------
133
+
134
+ The `.FigureCanvasBase ` class has now an `~.FigureCanvasBase.inaxes `
135
+ method to check whether a point is in an axes and returns the topmost
136
+ axes, else None.
125
137
126
138
cairo backend defaults to pycairo instead of cairocffi
127
- ------------------------------------------------------------
139
+ ------------------------------------------------------
140
+
128
141
This leads to faster import/runtime performance in some cases. The backend
129
142
will fall back to cairocffi in case pycairo isn't available.
130
143
131
144
132
145
Axes and Artists
133
- ===================
146
+ ================
147
+
134
148
axes_grid1 and axisartist Axes no longer draw spines twice
135
- ------------------------------------------------------------
149
+ ----------------------------------------------------------
150
+
136
151
Previously, spines of `axes_grid1 ` and `axisartist ` Axes would be drawn twice,
137
152
leading to a "bold" appearance. This is no longer the case.
138
153
139
154
140
155
Return type of ArtistInspector.get_aliases changed
141
156
--------------------------------------------------
142
- `ArtistInspector.get_aliases ` previously returned the set of aliases as
157
+ `. ArtistInspector.get_aliases ` previously returned the set of aliases as
143
158
``{fullname: {alias1: None, alias2: None, ...}} ``. The dict-to-None mapping
144
159
was used to simulate a set in earlier versions of Python. It has now been
145
160
replaced by a set, i.e. ``{fullname: {alias1, alias2, ...}} ``.
146
161
147
- This value is also stored in `ArtistInspector.aliasd `, which has likewise
162
+ This value is also stored in `. ArtistInspector.aliasd `, which has likewise
148
163
changed.
149
164
150
165
151
- `ConnectionPatch ` accepts arbitrary transforms
166
+ `. ConnectionPatch ` accepts arbitrary transforms
152
167
-----------------------------------------------
168
+
153
169
Alternatively to strings like ``"data" `` or ``"axes fraction" ``
154
170
`ConnectionPatch ` now accepts any `-matplotlib.transforms.Transform `
155
171
as input for the ``coordsA `` and ``coordsB `` argument. This allows to
@@ -159,21 +175,24 @@ systems. Also see the :doc:`Connect Simple01 example
159
175
160
176
161
177
mplot3d Line3D now allows {set,get}_data_3d
162
- --------------------------------------------
163
- Lines created with the 3d projection in mplot3d can now access the data using
164
- ``mplot3d.art3d.Line3D.get_data_3d() `` which returns a tuple of array_likes containing
165
- the (x, y, z) data. The equivalent ``mplot3d.art3d.Line3D.set_data_3d(x, y, z) ``
166
- can be used to modify the data of an existing Line3D.
178
+ -------------------------------------------
179
+
180
+ Lines created with the 3d projection in mplot3d can now access the
181
+ data using `~.mplot3d.art3d.Line3D.get_data_3d() ` which returns a
182
+ tuple of array_likes containing the (x, y, z) data. The equivalent
183
+ `~.mplot3d.art3d.Line3D.set_data_3d ` can be used to modify the data of
184
+ an existing Line3D.
167
185
168
186
169
187
``Axes3D.voxels `` now shades the resulting voxels
170
- ------------------------------------------------------------
171
- The :meth: `-mpl_toolkits.mplot3d.Axes3D.voxels ` method now takes a ``shade ``
172
- parameter that defaults to ``True ``. This shades faces based on their
173
- orientation, behaving just like the matching parameters to
188
+ -------------------------------------------------
189
+
190
+ The :meth: `-mpl_toolkits.mplot3d.Axes3D.voxels ` method now takes a
191
+ *shade * parameter that defaults to `True `. This shades faces based
192
+ on their orientation, behaving just like the matching parameters to
174
193
:meth: `-mpl_toolkits.mplot3d.Axes3D.trisurf ` and
175
- :meth: `-mpl_toolkits.mplot3d.Axes3D.bar3d `.
176
- The plot below shows how this affects the output.
194
+ :meth: `-mpl_toolkits.mplot3d.Axes3D.bar3d `. The plot below shows how
195
+ this affects the output.
177
196
178
197
.. plot ::
179
198
@@ -208,81 +227,105 @@ The plot below shows how this affects the output.
208
227
plt.show()
209
228
210
229
Axis and Ticks
211
- ===============
230
+ ==============
212
231
213
- Added `Axis.get_inverted ` and `Axis.set_inverted `
214
- -------------------------------------------------
215
- The `Axis.get_inverted ` and `Axis.set_inverted ` methods query and set whether
232
+ Added `. Axis.get_inverted ` and `. Axis.set_inverted `
233
+ ---------------------------------------------------
234
+ The `. Axis.get_inverted ` and `. Axis.set_inverted ` methods query and set whether
216
235
the axis uses "inverted" orientation (i.e. increasing to the left for the
217
236
x-axis and to the bottom for the y-axis).
218
237
219
- They perform tasks similar to `Axes.xaxis_inverted `, `Axes.yaxis_inverted `,
220
- `Axes.invert_xaxis `, and `Axes.invert_yaxis `, with the specific difference that
221
- `.set_inverted ` makes it easier to set the invertedness of an axis regardless
222
- of whether it had previously been inverted before.
238
+ They perform tasks similar to `.Axes.xaxis_inverted `,
239
+ `.Axes.yaxis_inverted `, `.Axes.invert_xaxis `, and
240
+ `.Axes.invert_yaxis `, with the specific difference that
241
+ `.Axes..set_inverted ` makes it easier to set the invertedness of an
242
+ axis regardless of whether it had previously been inverted before.
223
243
224
244
Adjust default minor tick spacing
225
- ----------------------------------
245
+ ---------------------------------
246
+
226
247
Default minor tick spacing was changed from 0.625 to 0.5 for major ticks spaced
227
248
2.5 units apart.
228
249
229
250
230
- `EngFormatter ` now accepts `usetex `, `useMathText ` as keyword only arguments
231
- ----------------------------------------------------------------------------
232
- A public API has been added to `EngFormatter ` to control how the numbers in the
233
- ticklabels will be rendered. By default, ``useMathText `` evaluates to
234
- ``rcParams['axes.formatter.use_mathtext'] `` and ``usetex `` evaluates to
235
- ``rcParams['text.usetex'] ``.
251
+ `.EngFormatter ` now accepts `usetex `, `useMathText ` as keyword only arguments
252
+ -----------------------------------------------------------------------------
236
253
237
- If either is ``True `` then the numbers will be encapsulated by ``$ `` signs.
238
- When using ``TeX `` this implies that the numbers will be shown in TeX's math
239
- font. When using mathtext, the ``$ `` signs around numbers will ensure unicode
240
- rendering (as implied by mathtext). This will make sure that the minus signs
241
- in the ticks are rendered as the unicode=minus (U+2212) when using mathtext
242
- (without relying on the ``fix_minus `` method).
254
+ A public API has been added to `EngFormatter ` to control how the
255
+ numbers in the ticklabels will be rendered. By default,
256
+ ``useMathText `` evaluates to
257
+ :rc: `rcParams['axes.formatter.use_mathtext'] ` and ``usetex `` evaluates
258
+ to :rc: `rcParams['text.usetex'] `.
259
+
260
+ If either is `True ` then the numbers will be encapsulated by ``$ ``
261
+ signs. When using ``TeX `` this implies that the numbers will be shown
262
+ in TeX's math font. When using mathtext, the ``$ `` signs around
263
+ numbers will ensure unicode rendering (as implied by mathtext). This
264
+ will make sure that the minus signs in the ticks are rendered as the
265
+ unicode=minus (U+2212) when using mathtext (without relying on the
266
+ `~.Fomatter.fix_minus ` method).
243
267
244
268
245
269
246
270
Animation and Interactivity
247
- ============================
271
+ ===========================
272
+
248
273
Support for forward/backward mouse buttons
249
274
-------------------------------------------
250
- Figure managers now support a ``button_press `` event for mouse buttons, similar
251
- to the ``key_press `` events. This allows binding actions to mouse buttons (see
252
- `.MouseButton `) The first application of this mechanism is support of forward/backward mouse
253
- buttons in figures created with the Qt5 backend.
254
275
276
+ Figure managers now support a ``button_press `` event for mouse
277
+ buttons, similar to the ``key_press `` events. This allows binding
278
+ actions to mouse buttons (see `.MouseButton `) The first application of
279
+ this mechanism is support of forward/backward mouse buttons in figures
280
+ created with the Qt5 backend.
255
281
256
- *progress_callback * argument to ani.save()
257
- -------------------------------------------
258
- The method .FuncAnimation.save() gained an optional *progress_callback * argument to notify the saving progress.
259
282
260
- Add ``cache_frame_data `` keyword-only argument into ``matplotlib.animation.FuncAnimation ``
261
- -------------------------------------------------------------------------------------------
262
- | ``matplotlib.animation.FuncAnimation`` has been caching frame data by default; however, this caching is not ideal in certain cases e.g. When ``FuncAnimation`` needs to be only drawn(not saved) interactively and memory required by frame data is quite large. By adding ``cache_frame_data`` keyword-only argument, users can now disable this caching; thereby, this new argument provides a fix for issue #8528.
283
+ *progress_callback * argument to `~.Animation.save() `
284
+ ----------------------------------------------------
285
+
286
+ The method .FuncAnimation.save() gained an optional
287
+ *progress_callback * argument to notify the saving progress.
288
+
289
+
290
+ Add ``cache_frame_data `` keyword-only argument into `.animation.FuncAnimation `
291
+ ------------------------------------------------------------------------------
292
+
293
+ `.matplotlib.animation.FuncAnimation ` has been caching frame data by
294
+ default; however, this caching is not ideal in certain cases e.g. When
295
+ `.FuncAnimation ` needs to be only drawn(not saved) interactively and
296
+ memory required by frame data is quite large. By adding
297
+ *cache_frame_data * keyword-only argument, users can now disable this
298
+ caching; thereby, this new argument provides a fix for issue
299
+ :ghissue: `8528 `.
263
300
264
301
265
302
Endless Looping GIFs with PillowWriter
266
303
--------------------------------------
267
- We acknowledge that most people want to watch a gif more than once. Saving an animation as a gif with PillowWriter now produces an endless looping gif.
268
304
305
+ We acknowledge that most people want to watch a gif more than
306
+ once. Saving an animation as a gif with PillowWriter now produces an
307
+ endless looping gif.
269
308
270
- Adjusted ``matplotlib.widgets.Slider `` to have vertical orientation
271
- --------------------------------------------------------------------
272
- The :class: `matplotlib.widgets.Slider ` widget now takes an optional argument
273
- ``orientation `` which indicates the direction (``'horizontal' `` or
274
- ``'vertical' ``) that the slider should take.
309
+
310
+ Adjusted `.matplotlib.widgets.Slider ` to have vertical orientation
311
+ ------------------------------------------------------------------
312
+
313
+ The :class: `matplotlib.widgets.Slider ` widget now takes an optional
314
+ argument *orientation * which indicates the direction
315
+ (``'horizontal' `` or ``'vertical' ``) that the slider should take.
275
316
276
317
Improved formatting of image values under cursor when a colorbar is present
277
318
---------------------------------------------------------------------------
319
+
278
320
When a colorbar is present, its formatter is now used to format the image
279
321
values under the mouse cursor in the status bar. For example, for an image
280
322
displaying the values 10,000 and 10,001, the statusbar will now (using default
281
323
settings) display the values as ``10000 `` and ``10001 ``), whereas both values
282
324
were previously displayed as ``1e+04 ``.
283
325
284
326
MouseEvent button attribute is now an IntEnum
285
- ----------------------------------------------
327
+ ---------------------------------------------
328
+
286
329
The :attr: `button ` attribute of `-.MouseEvent ` instances can take the values
287
330
None, 1 (left button), 2 (middle button), 3 (right button), "up" (scroll), and
288
331
"down" (scroll). For better legibility, the 1, 2, and 3 values are now
@@ -306,24 +349,35 @@ to load the matplotlibrc file from ``$MATPLOTLIBRC/matplotlibrc``.
306
349
307
350
Allow LaTeX code ``pgf.preamble `` and ``text.latex.preamble `` in MATPLOTLIBRC file
308
351
----------------------------------------------------------------------------------
309
- Previously, the rc file keys ``pgf.preamble `` and ``text.latex.preamble `` were parsed using commmas as separators. This would break valid LaTeX code, such as::
310
352
311
- \u sepackage[protrusion=true, expansion=false]{microtype}
353
+ Previously, the rc file keys :rc: `pgf.preamble ` and
354
+ :rc: `text.latex.preamble ` were parsed using commas as separators. This
355
+ would break valid LaTeX code, such as::
356
+
357
+ \usepackage[protrusion=true, expansion=false]{microtype}
312
358
313
- The parsing has been modified to pass the complete line to the LaTeX system,
314
- keeping all commas. Passing a list of strings from within a Python script still works as it used to.
359
+ The parsing has been modified to pass the complete line to the LaTeX
360
+ system, keeping all commas. Passing a list of strings from within a
361
+ Python script still works as it used to.
315
362
316
363
317
- Added support for MacOSX backend for PyPy
318
- ------------------------------------------
319
- Fixed issue with MacOSX backend for PyPy and also for non-framework Python
320
- installations.
364
+ Matplotlib no longer requires framework app build on MacOSX backend
365
+ -------------------------------------------------------------------
366
+
367
+ Previous versions of matplotlin required a Framework build of python to
368
+ work. The app type was updated to no longer require this, so the MacOSX
369
+ backend should work with non-framework python.
370
+
371
+
372
+ This also adds support support for the MacOSX backend for PyPy3.
373
+
321
374
322
375
323
376
New logging API
324
377
----------------
325
- `matplotlib.set_loglevel `/`.pyplot.set_loglevel ` can be called to display more
326
- (or less) detailed logging output.
378
+
379
+ `matplotlib.set_loglevel ` / `.pyplot.set_loglevel ` can be called to
380
+ display more (or less) detailed logging output.
327
381
328
382
329
383
===================
0 commit comments