Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0d08213

Browse filesBrowse files
committed
More intelligent linspace based on cmap.N
1 parent 3403cb0 commit 0d08213
Copy full SHA for 0d08213

File tree

Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-8
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -893,24 +893,25 @@ def _process_values(self, b=None):
893893
if b is not None:
894894
self._boundaries = np.asarray(b, dtype=float)
895895
if self.values is None and self.boundaries is not None:
896-
# define the outside indices
896+
# define the outside additions
897897
if self.extend == 'min':
898-
i = 0
898+
to_add = self._boundaries[0]
899899
elif self.extend == 'max':
900-
i = -1
900+
to_add = self._boundaries[-1]
901901
elif self.extend == 'both':
902-
i = [0, -1]
902+
to_add = self._boundaries[[0, -1]]
903903
elif self.extend == 'neither':
904-
i = slice(None)
904+
to_add = []
905905
# add values to the colorbar insides
906906
boundaries_inside = self._boundaries[self._inside]
907+
n_between = max((self.cmap.N-len(to_add))// \
908+
(len(boundaries_inside)-1), 1)
907909
self._values = np.linspace(boundaries_inside[:-1],
908910
np.roll(boundaries_inside, -1)[:-1],
909-
1000, endpoint = False,
910-
axis = -1).flatten()
911+
n_between, endpoint=False,
912+
axis=-1).flatten()
911913
self._values = np.append(self._values, boundaries_inside[-1])
912914
# add back in the boundaries for the extensions
913-
to_add = np.atleast_1d(self._boundaries[i])
914915
self._boundaries = np.sort(np.concatenate([to_add,
915916
self._values]))
916917
# calculate values at which to plot colors

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.