8000 Add the __add__ method, and doc. · matplotlib/matplotlib@f06bf46 · GitHub
[go: up one dir, main page]

Skip to content

Commit f06bf46

Browse files
committed
Add the __add__ method, and doc.
8000
1 parent 60ebf94 commit f06bf46

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/matplotlib/colors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,11 @@ def join(self, other, name=None, frac_self=None, N=None):
650650
# Note that `joined_cmap` will be 2/3 `cmap1`, and 1/3 `cmap2`
651651
# because of the default behavior of frac_self
652652
# (i.e. proportional to N of each cmap).
653+
654+
# This is also available as :meth:`Colormap.__add__`, so that
655+
# the following is possible:
656+
657+
joined_cmap = cmap1 + cmap2
653658
"""
654659
if N is None:
655660
N = self.N + other.N
@@ -664,6 +669,8 @@ def join(self, other, name=None, frac_self=None, N=None):
664669
# N is set by len of the vstack'd array:
665670
return ListedColormap(np.vstack((map0, map1)), name, )
666671

672+
__add__ = join
673+
667674
def truncate(self, minval=0.0, maxval=1.0, N=None):
668675
"""
669676
Truncate a colormap.

0 commit comments

Comments
 (0)
0