GeezerVison is showing github.com — minor bugfixes · matplotlib/matplotlib@c353303
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 186 | 186 | major_pad : float | 187 | 187 | Spacing between colorbars along the long axis | 188 | 188 |
| 189 | | -major_pad : float | | 189 | +minor_pad : float | 190 | 190 | Spacing between colorbars along the short axis | 191 | 191 | """) | 192 | 192 |
| @@ -1792,7 +1792,7 @@ def remove(self): | 1792 | 1792 | except AttributeError: | 1793 | 1793 | return | 1794 | 1794 | try: | 1795 | | - subplotspec = self.ax.get_subplotspec().get_gridspec()._subplot_spec | | 1795 | + subplotspec = ax.get_subplotspec().get_gridspec()._subplot_spec | 1796 | 1796 | except AttributeError: # use_gridspec was False | 1797 | 1797 | pos = ax.get_position(original=True) | 1798 | 1798 | ax._set_position(pos) | @@ -1926,7 +1926,7 @@ def _get_tight_packing_inside(self, bbox): | 1926 | 1926 | else: | 1927 | 1927 | raise ValueError("_set_tight_packing cannot be called " | 1928 | 1928 | "unless the MultivarColorbar was created " | 1929 | | - "by fig.multicolorbar(mappable).") | | 1929 | + "by fig.colorbar_multivar(mappable).") | 1930 | 1930 |
| 1931 | 1931 | def _get_original_position(self): | 1932 | 1932 | # comparable to axes.get_position(original=True) | @@ -2233,6 +2233,7 @@ def make_multivar_axes(parents, n_variates, n_major, location=None, orientation= | 2233 | 2233 |
| 2234 | 2234 | n_major : int | 2235 | 2235 | Number of colorbars along the long axis of the colorbars | | 2236 | + If -1, all colorbars are places sequentially along the long axis. | 2236 | 2237 | %(_make_multivar_axes_kw_doc)s | 2237 | 2238 |
| 2238 | 2239 | Returns | |
Collapse file Copy file name to clipboardExpand all lines: lib/matplotlib/figure.py +9-4Lines changed: 9 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1356,12 +1356,13 @@ def colorbar( | 1356 | 1356 |
| 1357 | 1357 | """ | 1358 | 1358 | if isinstance(mappable.cmap, mcolors.BivarColormap): | 1359 | | - raise ValueError("`Figure.colorbar` can only be together with a " | 1360 | | - "scalar colormap, please use `Figure.colorbar_bivar` " | | 1359 | + raise ValueError("`Figure.colorbar` can only be together with a scalar " | | 1360 | + "colormap, please use `Figure.colorbar_bivar` " | 1361 | 1361 | "when working with a bivariate colormap") | 1362 | 1362 | if isinstance(mappable.cmap, mcolors.MultivarColormap): | 1363 | | - raise ValueError("colorbar can only be together with a" | 1364 | | - "scalar colormap") | | 1363 | + raise ValueError("colorbar can only be together with a scalar " | | 1364 | + "colormap, please use `Figure.colorbar_multivar` " | | 1365 | + "when working with a bivariate colormap") | 1365 | 1366 |
| 1366 | 1367 | if ax is None: | 1367 | 1368 | ax = getattr(mappable, "axes", None) | @@ -1528,6 +1529,10 @@ def colorbar_multivar( | 1528 | 1529 | Defaults to the Axes that contains the mappable used to create the | 1529 | 1530 | colorbar. | 1530 | 1531 |
| | 1532 | + n_major : int | | 1533 | + Number of colorbars along the long axis of the colorbars. | | 1534 | + If -1, all colorbars are places sequentially along the long axis. | | 1535 | +
| 1531 | 1536 | Returns | 1532 | 1537 | ------- | 1533 | 1538 | multivariate_colorbar : `~matplotlib.colorbar.MultivarColorbar` | |
Collapse file Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_colorbar.py +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1583,8 +1583,8 @@ def test_bivar_cbar_ticklocations(): | 1583 | 1583 | with pytest.raises(ValueError, match='ticklocations must be a tuple of'): | 1584 | 1584 | cbar = fig.colorbar_bivar(ca, cax=ax, ticklocations=['left']) | 1585 | 1585 | cbar = fig.colorbar_bivar(ca, cax=ax, ticklocations=['left', 'top']) | 1586 | | - cbar.ax.yaxis.get_label_position() == 'left' | 1587 | | - cbar.ax.xaxis.get_label_position() == 'top' | | 1586 | + assert cbar.ax.yaxis.get_label_position() == 'left' | | 1587 | + assert cbar.ax.xaxis.get_label_position() == 'top' | 1588 | 1588 |
| 1589 | 1589 |
| 1590 | 1590 | def test_wrong_kind_colorbar(): | @@ -1757,7 +1757,11 @@ def test_multivar_cbar_set_label_limits(): | 1757 | 1757 | fig, ax = plt.subplots(1, 1) | 1758 | 1758 | mim = ax.imshow(data, cmap='3VarAddA') | 1759 | 1759 | cbs = fig.colorbar_multivar(mim) | 1760 | | - cbs[0].set_label('A') | 1761 | 1760 | assert len(cbs) == 3 | | 1761 | + cbs[0].set_label('A') | | 1762 | + assert cbs[0].ax.get_ylabel() == 'A' | | 1763 | + | 1762 | 1764 | mim.norm.vmin = (-1, -1, -1) | 1763 | 1765 | mim.norm.vmax = (1, 2, 3) | | 1766 | + np.testing.assert_allclose(cbs[0].ax.get_ylim(), (-1, 1)) | | 1767 | + np.testing.assert_allclose(cbs[2].ax.get_ylim(), (-1, 3)) |
|