Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e6648a7

Browse files
committed
DOC: Edit the 3.3 what's new based on review.
1 parent a43d8b3 commit e6648a7

File tree

1 file changed

+60
-26
lines changed

1 file changed

+60
-26
lines changed

doc/users/prev_whats_new/whats_new_3.3.0.rst

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,15 @@ as an alternative to ::
6262
fig.subplots(2, 2, gridspec_kw={"height_ratios": [3, 1]})
6363

6464

65-
New Turbo colormap
66-
------------------
65+
Turbo colormap
66+
--------------
6767

6868
Turbo is an improved rainbow colormap for visualization, created by the Google
6969
AI team for computer visualization and machine learning. Its purpose is to
7070
display depth and disparity data. Please see the `Google AI Blog
7171
<https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html>`_
7272
for further details.
7373

74-
Below shows Turbo and some other rainbow-esque colormaps:
75-
7674
.. plot::
7775

7876
gradient = np.linspace(0, 1, 256)
@@ -103,8 +101,8 @@ that pass through two points.
103101
ax.legend()
104102

105103

106-
New "extend" keyword to colors.BoundaryNorm
107-
-------------------------------------------
104+
``colors.BoundaryNorm`` supports *extend* keyword argument
105+
----------------------------------------------------------
108106

109107
`~.colors.BoundaryNorm` now has an *extend* keyword argument, analogous to
110108
*extend* in `~.axes.Axes.contourf`. When set to 'both', 'min', or 'max', it
@@ -191,8 +189,8 @@ New ``Axes.sharex``, ``Axes.sharey`` methods
191189
--------------------------------------------
192190

193191
These new methods allow sharing axes *immediately* after creating them. Note
194-
that they may *not* be used to share axes after any operation (e.g., drawing)
195-
has occurred on them.
192+
that behavior is indeterminate if axes are not shared immediately after
193+
creation.
196194

197195
For example, they can be used to selectively link some axes created all
198196
together using `~.Figure.subplot_mosaic`::
@@ -281,8 +279,8 @@ set with the new rcParameter :rc:`axes.titley`.
281279
plt.show()
282280

283281

284-
Dates now use a modern epoch
285-
----------------------------
282+
Dates use a modern epoch
283+
------------------------
286284

287285
Matplotlib converts dates to days since an epoch using `.dates.date2num` (via
288286
`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
299297
may also call `~.dates.set_epoch`, but it must be set *before* any date
300298
conversion or plotting is used.
301299

302-
If you have data stored as ordinal floats in the old epoch, a simple
303-
conversion (using the new epoch) is::
300+
If you have data stored as ordinal floats in the old epoch, you can convert
301+
them to the new ordinal using the following formula::
304302

305303
new_ordinal = old_ordinal + mdates.date2num(np.datetime64('0000-12-31'))
306304

307305

308306
tight_layout now supports suptitle
309307
----------------------------------
310308

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`:
313311

314312
.. plot::
315313

@@ -342,18 +340,30 @@ Allow tick formatters to be set with str or function inputs
342340
now accept `str` or function inputs in addition to `~.ticker.Formatter`
343341
instances. For a `str` a `~.ticker.StrMethodFormatter` is automatically
344342
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: {x:02}')
347+
ax.xaxis.set_minor_formatter(lambda x, pos: '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: {x:02}'))
354+
ax.xaxis.set_minor_formatter(
355+
mticker.FuncFormatter(lambda x, pos: 'low' if x < 2 else 'high'))
346356

347357

348358
Setting axes box aspect
349359
-----------------------
350360

351361
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 a usual 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 a non-image plot with the same axes dimensions next to an image plot with
366+
fixed (data-)aspect.
357367

358368
For use cases check out the :doc:`Axes box aspect
359369
</gallery/subplots_axes_and_figures/axes_box_aspect>` example.
@@ -424,7 +434,30 @@ explicit keyword argument *normalize* has been added. By default, the old
424434
behavior is preserved.
425435

426436
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\nsum(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\nsum(x) > 1')
428461

429462

430463
Simple syntax to select fonts by absolute path
@@ -445,8 +478,8 @@ accurately.
445478
rcParams improvements
446479
---------------------
447480

448-
``matplotlib.rc_context`` is now a ``contextlib.contextmanager``
449-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
481+
``matplotlib.rc_context`` can be used as a decorator
482+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
450483

451484
`matplotlib.rc_context` can now be used as a decorator (technically, it is now
452485
implemented as a `contextlib.contextmanager`), e.g., ::
@@ -457,9 +490,10 @@ implemented as a `contextlib.contextmanager`), e.g., ::
457490

458491
rcParams for controlling default "raise window" behavior
459492
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
463497

464498
Add generalized ``mathtext.fallback`` to rcParams
465499
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)