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

Skip to content

Commit a70468e

Browse files
committed
DOC: consolidate remaining whats new
1 parent 77f23da commit a70468e

5 files changed

Lines changed: 107 additions & 103 deletions

File tree

doc/users/next_whats_new/2020-04-23-ES-svg-metadata.rst

Lines changed: 0 additions & 9 deletions
This file was deleted.

doc/users/next_whats_new/2020-04-24-ES-pdf-pgf-metadata.rst

Lines changed: 0 additions & 8 deletions
This file was deleted.

doc/users/next_whats_new/2020-05-28-extend_kwarg_to_BoundaryNorm.rst

Lines changed: 0 additions & 49 deletions
This file was deleted.

doc/users/next_whats_new/2020-05-tac.rst

Lines changed: 0 additions & 37 deletions
This file was deleted.

doc/users/prev_whats_new/whats_new_3.3.0.rst

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,110 @@ support a parameter ``loc`` for simplified positioning. Supported values are
347347
'left', 'center', or 'right'. The default is controlled via
348348
:rc:`xaxis.labelposition` and :rc:`yaxis.labelposition`; the Colorbar label
349349
takes the rcParam based on its orientation.
350+
351+
Saving SVG now supports adding metadata
352+
---------------------------------------
353+
354+
When saving SVG files, metadata can now be passed which will be saved in the
355+
file using `Dublin Core`_ and `RDF`_. A list of valid metadata can be found in
356+
the documentation for `.FigureCanvasSVG.print_svg`.
357+
358+
.. _Dublin Core: https://www.dublincore.org/specifications/dublin-core/
359+
.. _RDF: https://www.w3.org/1999/.status/PR-rdf-syntax-19990105/status
360+
361+
Saving PDF metadata via PGF now consistent with PDF backend
362+
-----------------------------------------------------------
363+
364+
When saving PDF files using the PGF backend, passed metadata will be
365+
interpreted in the same way as with the PDF backend. Previously, this metadata
366+
was only accepted by the PGF backend when saving a multi-page PDF with
367+
`.backend_pgf.PdfPages`, but is now allowed when saving a single figure, as
368+
well.
369+
370+
New "extend" keyword to colors.BoundaryNorm
371+
-------------------------------------------
372+
373+
`~.colors.BoundaryNorm` now has an ``extend`` keyword argument, analogous to
374+
``extend`` in `~.axes.Axes.contourf`. When set to 'both', 'min', or 'max',
375+
it maps the corresponding out-of-range values to `~.colors.Colormap`
376+
lookup-table indices near the appropriate ends of their range so that the
377+
colors for out-of range values are adjacent to, but distinct from, their
378+
in-range neighbors. The colorbar inherits the ``extend`` argument from the
379+
norm, so with ``extend='both'``, for example, the colorbar will have triangular
380+
extensions for out-of-range values with colors that differ from adjacent in-range
381+
colors.
382+
383+
.. plot::
384+
385+
import matplotlib.pyplot as plt
386+
from matplotlib.colors import BoundaryNorm
387+
import numpy as np
388+
389+
# Make the data
390+
dx, dy = 0.05, 0.05
391+
y, x = np.mgrid[slice(1, 5 + dy, dy),
392+
slice(1, 5 + dx, dx)]
393+
z = np.sin(x) ** 10 + np.cos(10 + y * x) * np.cos(x)
394+
z = z[:-1, :-1]
395+
396+
# Z roughly varies between -1 and +1.
397+
# Color boundary levels range from -0.8 to 0.8, so there are out-of-bounds
398+
# areas.
399+
levels = [-0.8, -0.5, -0.2, 0.2, 0.5, 0.8]
400+
cmap = plt.get_cmap('PiYG')
401+
402+
fig, axs = plt.subplots(nrows=2, constrained_layout=True, sharex=True)
403+
404+
# Before this change:
405+
norm = BoundaryNorm(levels, ncolors=cmap.N)
406+
im = axs[0].pcolormesh(x, y, z, cmap=cmap, norm=norm)
407+
fig.colorbar(im, ax=axs[0], extend='both')
408+
axs[0].axis([x.min(), x.max(), y.min(), y.max()])
409+
axs[0].set_title("Colorbar with extend='both'")
410+
411+
# With the new keyword:
412+
norm = BoundaryNorm(levels, ncolors=cmap.N, extend='both')
413+
im = axs[1].pcolormesh(x, y, z, cmap=cmap, norm=norm)
414+
fig.colorbar(im, ax=axs[1]) # note that the colorbar is updated accordingly
415+
axs[1].axis([x.min(), x.max(), y.min(), y.max()])
416+
axs[1].set_title("BoundaryNorm with extend='both'")
417+
418+
plt.show()
419+
420+
Add API for composing semantic axes layouts from text or nested lists
421+
---------------------------------------------------------------------
422+
423+
The `.Figure` class has a provisional method to generate complex grids
424+
of named `.axes.Axes` based on nested list input or ASCII art:
425+
426+
.. plot::
427+
:include-source: True
428+
429+
axd = plt.figure(constrained_layout=True).subplot_mosaic(
430+
[["Top", "Top", "Edge"],
431+
["Left", ".", "Edge"]]
432+
)
433+
for k, ax in axd.items():
434+
ax.text(0.5, 0.5, k,
435+
ha='center', va='center', fontsize=36,
436+
color='darkgrey')
437+
438+
or as a string (with single-character Axes labels):
439+
440+
.. plot::
441+
:include-source: True
442+
443+
axd = plt.figure(constrained_layout=True).subplot_mosaic(
444+
"""
445+
TTE
446+
L.E
447+
""")
448+
for k, ax in axd.items():
449+
ax.text(0.5, 0.5, k,
450+
ha='center', va='center', fontsize=36,
451+
color='darkgrey')
452+
453+
454+
455+
See :ref:`sphx_glr_tutorials_provisional_mosaic.py` for more
456+
details and examples.

0 commit comments

Comments
 (0)