@@ -62,17 +62,15 @@ as an alternative to ::
62
62
fig.subplots(2, 2, gridspec_kw={"height_ratios": [3, 1]})
63
63
64
64
65
- New Turbo colormap
66
- ------------------
65
+ Turbo colormap
66
+ --------------
67
67
68
68
Turbo is an improved rainbow colormap for visualization, created by the Google
69
69
AI team for computer visualization and machine learning. Its purpose is to
70
70
display depth and disparity data. Please see the `Google AI Blog
71
71
<https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html> `_
72
72
for further details.
73
73
74
- Below shows Turbo and some other rainbow-esque colormaps:
75
-
76
74
..plot ::
77
75
78
76
gradient = np.linspace(0, 1, 256)
@@ -103,8 +101,8 @@ that pass through two points.
103
101
ax.legend()
104
102
105
103
106
- New " extend" keywordto colors.BoundaryNorm
107
- -------------------------------------------
104
+ `` colors.BoundaryNorm `` supports * extend * keywordargument
105
+ ----------------------------------------------------------
108
106
109
107
`~.colors.BoundaryNorm ` now has an *extend * keyword argument, analogous to
110
108
*extend * in `~.axes.Axes.contourf `. When set to 'both', 'min', or 'max', it
@@ -281,8 +279,8 @@ set with the new rcParameter :rc:`axes.titley`.
281
279
plt.show()
282
280
283
281
284
- Datesnow use a modern epoch
285
- ----------------------------
282
+ Dates use a modern epoch
283
+ ------------------------
286
284
287
285
Matplotlib converts dates to days since an epoch using `.dates.date2num ` (via
288
286
`matplotlib.units `). Previously, an epoch of ``0000-12-31T00:00:00 `` was used
@@ -299,17 +297,17 @@ by `~.dates.get_epoch`, and there is a new :rc:`date.epoch` rcParam. The user
299
297
may also call `~.dates.set_epoch `, but it must be set *before * any date
300
298
conversion or plotting is used.
301
299
302
- If you have data stored as ordinal floats in the old epoch,a simple
303
- conversion (using the newepoch) is ::
300
+ If you have data stored as ordinal floats in the old epoch,you can convert
301
+ them to the newordinal using the following formula ::
304
302
305
303
new_ordinal = old_ordinal + mdates.date2num(np.datetime64('0000-12-31'))
306
304
307
305
308
306
tight_layout now supports suptitle
309
307
----------------------------------
310
308
311
- Previous versions did not consider `.Figure.suptitle `,and so it may overlap
312
- with other artists after calling `~.Figure.tight_layout `:
309
+ Previous versions did not consider `.Figure.suptitle `, so it may overlap with
310
+ other artists after calling `~.Figure.tight_layout `:
313
311
314
312
..plot ::
315
313
@@ -342,18 +340,30 @@ Allow tick formatters to be set with str or function inputs
342
340
now accept `str ` or function inputs in addition to `~.ticker.Formatter `
343
341
instances. For a `str ` a `~.ticker.StrMethodFormatter ` is automatically
344
342
generated and used. For a function a `~.ticker.FuncFormatter ` is automatically
345
- generated and used.
343
+ generated and used. In other words,
344
+ ::
345
+
346
+ ax.xaxis.set_major_formatter('price: {:02}')
347
+ ax.xaxis.set_minor_formatter(lambda x, _ : 'low' if x < 2 else 'high')
348
+
349
+ are shortcuts for::
350
+
351
+ import matplotlib.ticker as mticker
352
+
353
+ ax.xaxis.set_major_formatter(mticker.StrMethodFormatter('price: {:02}'))
354
+ ax.xaxis.set_minor_formatter(
355
+ mticker.FuncFormatter(lambda x, _ : 'low' if x < 2 else 'high'))
346
356
347
357
348
358
Setting axes box aspect
349
359
-----------------------
350
360
351
361
It is now possible to set the aspect of an axes box directly via
352
- `~.Axes.set_box_aspect `. The box aspect is the ratio between axes height
353
- and axes width in physical units, independent of the data limits.
354
- This is useful to, e.g., produce a square plot, independent of the data it
355
- contains, or to have ausual plot with the same axes dimensions next to
356
- an image plot with fixed (data-)aspect.
362
+ `~.Axes.set_box_aspect `. The box aspect is the ratio between axes height and
363
+ axes width in physical units, independent of the data limits. This is useful
364
+ to, e.g., produce a square plot, independent of the data it contains, or to
365
+ have anon-image plot with the same axes dimensions next to an image plot with
366
+ fixed (data-)aspect.
357
367
358
368
For use cases check out the:doc: `Axes box aspect
359
369
</gallery/subplots_axes_and_figures/axes_box_aspect>` example.
@@ -424,7 +434,30 @@ explicit keyword argument *normalize* has been added. By default, the old
424
434
behavior is preserved.
425
435
426
436
By passing *normalize *, one can explicitly control whether any rescaling takes
427
- place and whether partial pies should be created.
437
+ place or whether partial pies should be created. If normalization is disabled,
438
+ and ``sum(x) > 1 ``, then an error is raised.
439
+
440
+ ..plot ::
441
+
442
+ def label(x):
443
+ return [str(v) for v in x]
444
+
445
+ x = np.array([0.25, 0.3, 0.3])
446
+ fig, ax = plt.subplots(2, 2, constrained_layout=True)
447
+
448
+ ax[0, 0].pie(x, autopct='%1.1f%%', labels=label(x), normalize=False)
449
+ ax[0, 0].set_title('normalize=False')
450
+ ax[0, 1].pie(x, autopct='%1.2f%%', labels=label(x), normalize=True)
451
+ ax[0, 1].set_title('normalize=True')
452
+
453
+ # For the purposes of keeping the documentation build warning-free, and
454
+ # future proof for when the deprecation is made permanent, we pass
455
+ # *normalize * here explicitly anyway.
456
+ ax[1, 0].pie(x, autopct='%1.2f%%', labels=label(x), normalize=False)
457
+ ax[1, 0].set_title('normalize unspecified\n sum(x) < 1')
458
+ ax[1, 1].pie(x * 10, autopct='%1.2f%%', labels=label(x * 10),
459
+ normalize=True)
460
+ ax[1, 1].set_title('normalize unspecified\n sum(x) > 1')
428
461
429
462
430
463
Simple syntax to select fonts by absolute path
@@ -445,8 +478,8 @@ accurately.
445
478
rcParams improvements
446
479
---------------------
447
480
448
- ``matplotlib.rc_context ``is now a `` contextlib.contextmanager ``
449
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481
+ ``matplotlib.rc_context ``can be used as a decorator
482
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
450
483
451
484
`matplotlib.rc_context ` can now be used as a decorator (technically, it is now
452
485
implemented as a `contextlib.contextmanager `), e.g., ::
@@ -457,9 +490,10 @@ implemented as a `contextlib.contextmanager`), e.g., ::
457
490
458
491
rcParams for controlling default "raise window" behavior
459
492
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
460
- The new config option:rc: `figure.raise_window ` allows to disable
461
- raising the plot window when calling `~.pyplot.show ` or `~.pyplot.pause `.
462
- The ``MacOSX `` backend is currently not supported.
493
+
494
+ The new config option:rc: `figure.raise_window ` allows disabling of the raising
495
+ of the plot window when calling `~.pyplot.show ` or `~.pyplot.pause `. The
496
+ ``MacOSX `` backend is currently not supported.
463
497
464
498
Add generalized ``mathtext.fallback `` to rcParams
465
499
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~