File: behaviour.rst

package info (click to toggle)
matplotlib 3.10.7%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 72,816 kB
  • sloc: python: 147,545; cpp: 62,988; objc: 1,679; ansic: 1,426; javascript: 788; makefile: 92; sh: 53
file content (135 lines) | stat: -rw-r--r-- 6,329 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
Behaviour Changes
-----------------

All Axes have ``get_subplotspec`` and ``get_gridspec`` methods now, which returns None for Axes not positioned via a gridspec
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, this method was only present for Axes positioned via a gridspec.
Following this change, checking ``hasattr(ax, "get_gridspec")`` should now be
replaced by ``ax.get_gridspec() is not None``.  For compatibility with older
Matplotlib releases, one can also check
``hasattr(ax, "get_gridspec") and ax.get_gridspec() is not None``.

``HostAxesBase.get_aux_axes`` now defaults to using the same base axes class as the host axes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If using an ``mpl_toolkits.axisartist``-based host Axes, the parasite Axes will
also be based on ``mpl_toolkits.axisartist``.  This behavior is consistent with
``HostAxesBase.twin``, ``HostAxesBase.twinx``, and ``HostAxesBase.twiny``.

``plt.get_cmap`` and ``matplotlib.cm.get_cmap`` return a copy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Formerly, `~.pyplot.get_cmap` and ``matplotlib.cm.get_cmap`` returned a global version
of a `.Colormap`. This was prone to errors as modification of the colormap would
propagate from one location to another without warning. Now, a new copy of the colormap
is returned.

``TrapezoidMapTriFinder`` uses different random number generator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The random number generator used to determine the order of insertion of
triangle edges in ``TrapezoidMapTriFinder`` has changed. This can result in a
different triangle index being returned for a point that lies exactly on an
edge between two triangles. This can also affect triangulation interpolation
and refinement algorithms that use ``TrapezoidMapTriFinder``.

``FuncAnimation(save_count=None)``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Passing ``save_count=None`` to `.FuncAnimation` no longer limits the number
of frames to 100. Make sure that it either can be inferred from *frames*
or provide an integer *save_count*.

``CenteredNorm`` halfrange is not modified when vcenter changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, the **halfrange** would expand in proportion to the
amount that **vcenter** was moved away from either **vmin** or **vmax**.
Now, the halfrange remains fixed when vcenter is changed, and **vmin** and
**vmax** are updated based on the **vcenter** and **halfrange** values.

For example, this is what the values were when changing vcenter previously.

.. code-block:: python

    norm = CenteredNorm(vcenter=0, halfrange=1)
    # Move vcenter up by one
    norm.vcenter = 1
    # updates halfrange and vmax (vmin stays the same)
    # norm.halfrange == 2, vmin == -1, vmax == 3

and now, with that same example

.. code-block:: python

    norm = CenteredNorm(vcenter=0, halfrange=1)
    norm.vcenter = 1
    # updates vmin and vmax (halfrange stays the same)
    # norm.halfrange == 1, vmin == 0, vmax == 2

The **halfrange** can be set manually or ``norm.autoscale()``
can be used to automatically set the limits after setting **vcenter**.

``fig.subplot_mosaic`` no longer passes the ``gridspec_kw`` args to nested gridspecs.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For nested `.Figure.subplot_mosaic` layouts, it is almost always
inappropriate for *gridspec_kw* arguments to be passed to lower nest
levels, and these arguments are incompatible with the lower levels in
many cases. This dictionary is no longer passed to the inner
layouts. Users who need to modify *gridspec_kw* at multiple levels
should use `.Figure.subfigures` to get nesting, and construct the
inner layouts with `.Figure.subplots` or `.Figure.subplot_mosaic`.

``HPacker`` alignment with **bottom** or **top** are now correct
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, the **bottom** and **top** alignments were swapped.
This has been corrected so that the alignments correspond appropriately.

On Windows only fonts known to the registry will be discovered
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously, Matplotlib would recursively walk user and system font directories
to discover fonts, however this lead to a number of undesirable behaviors
including finding deleted fonts. Now Matplotlib will only find fonts that are
known to the Windows registry.

This means that any user installed fonts must go through the Windows font
installer rather than simply being copied to the correct folder.

This only impacts the set of fonts Matplotlib will consider when using
`matplotlib.font_manager.findfont`. To use an arbitrary font, directly pass the
path to a font as shown in
:doc:`/gallery/text_labels_and_annotations/font_file`.

``QuadMesh.set_array`` now always raises ``ValueError`` for inputs with incorrect shapes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It could previously also raise `TypeError` in some cases.

``contour`` and ``contourf`` auto-select suitable levels when given boolean inputs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If the height array given to `.Axes.contour` or `.Axes.contourf` is of bool
dtype and *levels* is not specified, *levels* now defaults to ``[0.5]`` for
`~.Axes.contour` and ``[0, 0.5, 1]`` for `.Axes.contourf`.

``contour`` no longer warns if no contour lines are drawn.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This can occur if the user explicitly passes a ``levels`` array with no values
between ``z.min()`` and ``z.max()``; or if ``z`` has the same value everywhere.

``AxesImage.set_extent`` now raises ``TypeError`` for unknown keyword arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It previously raised a `ValueError`.

Change of ``legend(loc="best")`` behavior
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The algorithm of the auto-legend locator has been tweaked to better handle
non rectangular patches. Additional details on this change can be found in
:ghissue:`9580` and :ghissue:`9598`.