8000 [NF] Add 'truncate' and 'join' methods to colormaps. by lkilcher · Pull Request #7716 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[NF] Add 'truncate' and 'join' methods to colormaps. #7716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add the __add__ method, and doc.
  • Loading branch information
lkilcher committed May 17, 2018
commit f06bf467ccc275903dfcaac92ebf52a0e46c74e7
7 changes: 7 additions & 0 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,11 @@ def join(self, other, name=None, frac_self=None, N=None):
# Note that `joined_cmap` will be 2/3 `cmap1`, and 1/3 `cmap2`
# because of the default behavior of frac_self
# (i.e. proportional to N of each cmap).

# This is also available as :meth:`Colormap.__add__`, so that
# the following is possible:

joined_cmap = cmap1 + cmap2
"""
if N is None:
N = self.N + other.N
Expand All @@ -664,6 +669,8 @@ def join(self, other, name=None, frac_self=None, N=None):
# N is set by len of the vstack'd array:
return ListedColormap(np.vstack((map0, map1)), name, )

__add__ = join

def truncate(self, minval=0.0, maxval=1.0, N=None):
"""
Truncate a colormap.
Expand Down
0