@@ -69,6 +69,25 @@ See :doc:`/gallery/subplots_axes_and_figures/subfigures` for further details.
69
69
70
70
plt.show()
71
71
72
+ Single-line string notation for ``subplot_mosaic ``
73
+ --------------------------------------------------
74
+
75
+ `.Figure.subplot_mosaic ` and `.pyplot.subplot_mosaic ` now accept a single-line
76
+ string, using semicolons to delimit rows. Namely, ::
77
+
78
+ plt.subplot_mosaic(
79
+ """
80
+ AB
81
+ CC
82
+ """)
83
+
84
+ may be written as the shorter:
85
+
86
+ .. plot ::
87
+ :include-source:
88
+
89
+ plt.subplot_mosaic("AB;CC")
90
+
72
91
Changes to behavior of Axes creation methods (``gca ``, ``add_axes ``, ``add_subplot ``)
73
92
-------------------------------------------------------------------------------------
74
93
@@ -219,6 +238,24 @@ must match the size of *x*).
219
238
errorevery=[False, True, True, False, True] * 3)
220
239
ax[1].set_title('errorevery=[False, True, True, False, True] * 3')
221
240
241
+ ``hexbin `` supports data reference for *C * parameter
242
+ ----------------------------------------------------
243
+
244
+ As with the *x * and *y * parameters, `.Axes.hexbin ` now supports passing the *C *
245
+ parameter using a data reference.
246
+
247
+ .. plot ::
248
+ :include-source:
249
+
250
+ data = {
251
+ 'a': np.random.rand(1000),
252
+ 'b': np.random.rand(1000),
253
+ 'c': np.random.rand(1000),
254
+ }
255
+
256
+ fig, ax = plt.subplots()
257
+ ax.hexbin('a', 'b', C='c', data=data, gridsize=10)
258
+
222
259
Support callable for formatting of Sankey labels
223
260
------------------------------------------------
224
261
@@ -349,6 +386,16 @@ nothing.
349
386
verticalalignment='bottom', horizontalalignment='center')
350
387
ax.add_patch(patch)
351
388
389
+ ``TickedStroke `` patheffect
390
+ ---------------------------
391
+
392
+ The new `.TickedStroke ` patheffect can be used to produce lines with a ticked
393
+ style. This can be used to, e.g., distinguish the valid and invalid sides of
394
+ the constraint boundaries in the solution space of optimizations.
395
+
396
+ .. figure :: /gallery/misc/images/sphx_glr_tickedstroke_demo_002.png
397
+ :target: /gallery/misc/tickedstroke_demo.html
398
+
352
399
353
400
Colors and colormaps
354
401
====================
@@ -501,8 +548,8 @@ New ``cm.unregister_cmap`` function
501
548
`.cm.unregister_cmap ` allows users to remove a colormap that they have
502
549
previously registered.
503
550
504
- New CenteredNorm for symmetrical data around a center
505
- -----------------------------------------------------
551
+ New `` CenteredNorm `` for symmetrical data around a center
552
+ ---------------------------------------------------------
506
553
507
554
In cases where data is symmetrical around a center, for example, positive and
508
555
negative anomalies around a center zero, `~.matplotlib.colors.CenteredNorm ` is
@@ -536,6 +583,41 @@ the *halfrange* argument.
536
583
See :doc: `/tutorials/colors/colormapnorms ` for an example and more details
537
584
about data normalization.
538
585
586
+ New ``FuncNorm `` for arbitrary normalizations
587
+ ---------------------------------------------
588
+
589
+ The `.FuncNorm ` allows for arbitrary normalization using functions for the
590
+ forward and inverse.
591
+
592
+ .. plot ::
593
+
594
+ from matplotlib.colors import FuncNorm
595
+
596
+ def forward(x):
597
+ return x**2
598
+ def inverse(x):
599
+ return np.sqrt(x)
600
+
601
+ norm = FuncNorm((forward, inverse), vmin=0, vmax=3)
602
+
603
+ np.random.seed(20201004)
604
+ data = np.random.normal(size=(3, 4), loc=1)
605
+
606
+ fig, ax = plt.subplots()
607
+ pc = ax.pcolormesh(data, norm=norm)
608
+ fig.colorbar(pc)
609
+ ax.set_title('squared normalization')
610
+
611
+ # add text annotation
612
+ for irow, data_row in enumerate(data):
613
+ for icol, val in enumerate(data_row):
614
+ ax.text(icol + 0.5, irow + 0.5, f'{val:.2f}', color='C0',
615
+ size=16, va='center', ha='center')
616
+ plt.show()
617
+
618
+ See :doc: `/tutorials/colors/colormapnorms ` for an example and more details
619
+ about data normalization.
620
+
539
621
GridSpec-based colorbars can now be positioned above or to the left of the main axes
540
622
------------------------------------------------------------------------------------
541
623
@@ -634,6 +716,40 @@ of the transform affect the text direction.
634
716
math_expr = r"$ x \o verset{f}{\r ightarrow} y \u nderset{f}{\l eftarrow} z $"
635
717
plt.text(0.4, 0.5, math_expr, usetex=False)
636
718
719
+ *math_fontfamily * parameter to change ``Text `` font family
720
+ ----------------------------------------------------------
721
+
722
+ The new *math_fontfamily * parameter may be used to change the family of fonts
723
+ for each individual text element in a plot. If no parameter is set, the global
724
+ value :rc: `mathtext.fontset ` will be used.
725
+
726
+ .. figure :: /gallery/text_labels_and_annotations/images/sphx_glr_mathtext_fontfamily_example_001.png
727
+ :target: /gallery/text_labels_and_annotations/mathtext_fontfamily_example.html
728
+
729
+ ``TextArea ``/``AnchoredText `` support *horizontalalignment *
730
+ -----------------------------------------------------------
731
+
732
+ The horizontal alignment of text in a `.TextArea ` or `.AnchoredText ` may now be
733
+ specified, which is mostly effective for multiline text:
734
+
735
+ .. plot ::
736
+
737
+ from matplotlib.offsetbox import AnchoredText
738
+
739
+ fig, ax = plt.subplots()
740
+
741
+ text0 = AnchoredText("test\n test long text", loc="center left",
742
+ pad=0.2, prop={"ha": "left"})
743
+ ax.add_artist(text0)
744
+
745
+ text1 = AnchoredText("test\n test long text", loc="center",
746
+ pad=0.2, prop={"ha": "center"})
747
+ ax.add_artist(text1)
748
+
749
+ text2 = AnchoredText("test\n test long text", loc="center right",
750
+ pad=0.2, prop={"ha": "right"})
751
+ ax.add_artist(text2)
752
+
637
753
PDF supports URLs on ``Text `` artists
638
754
-------------------------------------
639
755
@@ -704,8 +820,8 @@ It is now possible to set :rc:`image.cmap` to a `.Colormap` instance, such as a
704
820
colormap created with the new `~.Colormap.set_extremes ` above. (This can only
705
821
be done from Python code, not from the :file: `matplotlibrc ` file.)
706
822
707
- The color of ticks and tick labels can be set independently using rcParams
708
- --------------------------------------------------------------------------
823
+ Tick and tick label colors can be set independently using rcParams
824
+ ------------------------------------------------------------------
709
825
710
826
Previously, :rc: `xtick.color ` defined both the tick color and the label color.
711
827
The label color can now be set independently using :rc: `xtick.labelcolor `. It
@@ -818,6 +934,32 @@ callbacks for event listeners on UI elements so that your plots can have some
818
934
playback control UI.
819
935
820
936
937
+ Sphinx extensions
938
+ =================
939
+
940
+ ``plot_directive `` *caption * option
941
+ -----------------------------------
942
+
943
+ Captions were previously supported when using the ``plot_directive `` directive
944
+ with an external source file by specifying content::
945
+
946
+ .. plot:: path/to/plot.py
947
+
948
+ This is the caption for the plot.
949
+
950
+ The ``:caption: `` option allows specifying the caption for both external::
951
+
952
+ .. plot:: path/to/plot.py
953
+ :caption: This is the caption for the plot.
954
+
955
+ and inline plots::
956
+
957
+ .. plot::
958
+ :caption: This is a caption for the plot.
959
+
960
+ plt.plot([1, 2, 3])
961
+
962
+
821
963
Backend-specific improvements
822
964
=============================
823
965
@@ -834,3 +976,62 @@ significantly smaller file sizes.
834
976
To ensure this happens do not place vector elements between raster ones.
835
977
836
978
To inhibit this merging set ``Figure.suppressComposite `` to True.
979
+
980
+ Support raw/rgba frame format in ``FFMpegFileWriter ``
981
+ -----------------------------------------------------
982
+
983
+ When using `.FFMpegFileWriter `, the *frame_format * may now be set to ``"raw" ``
984
+ or ``"rgba" ``, which may be slightly faster than an image format, as no
985
+ encoding/decoding need take place between Matplotlib and FFmpeg.
986
+
987
+ nbAgg/WebAgg support middle-click and double-click
988
+ --------------------------------------------------
989
+
990
+ Double click events are now supported by the nbAgg and WebAgg backends.
991
+ Formerly, WebAgg would report middle-click events as right clicks, but now
992
+ reports the correct button type.
993
+
994
+ nbAgg support binary communication
995
+ ----------------------------------
996
+
997
+ If the web browser and notebook support binary websockets, nbAgg will now use
998
+ them for slightly improved transfer of figure display.
999
+
1000
+ Indexed color for PNG images in PDF files when possible
1001
+ -------------------------------------------------------
1002
+
1003
+ When PNG images have 256 colors or fewer, they are converted to indexed color
1004
+ before saving them in a PDF. This can result in a significant reduction in file
1005
+ size in some cases. This is particularly true for raster data that uses a
1006
+ colormap but no interpolation, such as Healpy mollview plots. Currently, this
1007
+ is only done for RGB images.
1008
+
1009
+ Improved font subsettings in PDF/PS
1010
+ -----------------------------------
1011
+
1012
+ Font subsetting in PDF and PostScript has been re-written from the embedded
1013
+ ``ttconv `` C code to Python. Some composite characters and outlines may have
1014
+ changed slightly. This fixes ttc subsetting in PDF, and adds support for
1015
+ subsetting of type 3 OTF fonts, resulting in smaller files (much smaller when
1016
+ using CJK fonts), and avoids running into issues with type 42 embedding and
1017
+ certain PDF readers such as Acrobat Reader.
1018
+
1019
+ Kerning added to strings in PDFs
1020
+ --------------------------------
1021
+
1022
+ As with text produced in the Agg backend (see :ref: `the previous what's new
1023
+ entry <whats-new-3-2-0-kerning>` for examples), PDFs now include kerning in
1024
+ text strings.
1025
+
1026
+ Fully-fractional HiDPI in QtAgg
1027
+ -------------------------------
1028
+
1029
+ Fully-fractional HiDPI (that is, HiDPI ratios that are not whole integers) was
1030
+ added in Qt 5.14, and is now supported by the QtAgg backend when using this
1031
+ version of Qt or newer.
1032
+
1033
+ wxAgg supports fullscreen toggle
1034
+ --------------------------------
1035
+
1036
+ The wxAgg backend supports toggling fullscreen using the :kbd: `f ` shortcut, or
1037
+ the manager function `.FigureManagerBase.full_screen_toggle `.
0 commit comments