| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -627,8 +627,12 @@ def _add_solids(self, X, Y, C): | |||
| 627 | 627 | if not self.drawedges: | |
| 628 | 628 | if len(self._y) >= self.n_rasterize: | |
| 629 | 629 | self.solids.set_rasterized(True) | |
| 630 | - self.dividers.set_segments( | ||
| 631 | - np.dstack([X, Y])[1:-1] if self.drawedges else []) | ||
| 630 | + if self.drawedges: | ||
| 631 | + start_idx = 0 if self._extend_lower() else 1 | ||
| 632 | + end_idx = len(X) if self._extend_upper() else -1 | ||
| 633 | + self.dividers.set_segments(np.dstack([X, Y])[start_idx:end_idx]) | ||
| 634 | + else: | ||
| 635 | + self.dividers.set_segments([]) | ||
| 632 | 636 | ||
| 633 | 637 | def _add_solids_patches(self, X, Y, C, mappable): | |
| 634 | 638 | hatches = mappable.hatches * len(C) # Have enough hatches. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -929,6 +929,30 @@ def test_proportional_colorbars(): | |||
| 929 | 929 | fig.colorbar(CS3, spacing=spacings[j], ax=axs[i, j]) | |
| 930 | 930 | ||
| 931 | 931 | ||
| 932 | + @pytest.mark.parametrize("extend, coloroffset, res", [ | ||
| 933 | + ('both', 1, [np.array([[0., 0.], [0., 1.]]), | ||
| 934 | + np.array([[1., 0.], [1., 1.]]), | ||
| 935 | + np.array([[2., 0.], [2., 1.]])]), | ||
| 936 | + ('min', 0, [np.array([[0., 0.], [0., 1.]]), | ||
| 937 | + np.array([[1., 0.], [1., 1.]])]), | ||
| 938 | + ('max', 0, [np.array([[1., 0.], [1., 1.]]), | ||
| 939 | + np.array([[2., 0.], [2., 1.]])]), | ||
| 940 | + ('neither', -1, [np.array([[1., 0.], [1., 1.]])]) | ||
| 941 | + ]) | ||
| 942 | + def test_colorbar_extend_drawedges(extend, coloroffset, res): | ||
| 943 | + cmap = plt.get_cmap("viridis") | ||
| 944 | + bounds = np.arange(3) | ||
| 945 | + nb_colors = len(bounds) + coloroffset | ||
| 946 | + colors = cmap(np.linspace(100, 255, nb_colors).astype(int)) | ||
| 947 | + cmap, norm = mcolors.from_levels_and_colors(bounds, colors, extend=extend) | ||
| 948 | + | ||
| 949 | + plt.figure(figsize=(5, 1)) | ||
| 950 | + ax = plt.subplot(111) | ||
| 951 | + cbar = Colorbar(ax, cmap=cmap, norm=norm, orientation='horizontal', | ||
| 952 | + drawedges=True) | ||
| 953 | + assert np.all(np.equal(cbar.dividers.get_segments(), res)) | ||
| 954 | + | ||
| 955 | + | ||
| 932 | 956 | def test_negative_boundarynorm(): | |
| 933 | 957 | fig, ax = plt.subplots(figsize=(1, 3)) | |
| 934 | 958 | cmap = plt.get_cmap("viridis") | |
| Back | FazBrowse Home | New Git URL |
0 commit comments