@@ -589,21 +589,21 @@ def reversed(self, name=None):
589
589
"""
590
590
raise NotImplementedError ()
591
591
592
- def join (self , other , name = None , frac_self = None , N = None ):
592
+ def join (self , other , frac_self = None , name = None , N = None ):
593
593
"""
594
594
Join colormap `self` to `other` and return the new colormap.
595
595
596
596
Parameters
597
597
----------
598
598
other : cmap
599
599
The other colormap to be joined to this one.
600
- name : str, optional
601
- The name for the reversed colormap. If it's None the
602
- name will be ``self.name + '-' + other.name``.
603
600
frac_self : float in the interval ``(0.0, 1.0)``, optional
604
601
The fraction of the new colormap that should be occupied
605
602
by self. By default, this is ``self.N / (self.N +
606
603
other.N)``.
604
+ name : str, optional
605
+ The name for the joined colormap. This defaults to
606
+ ``self.name + '+' + other.name``
607
607
N : int
608
608
The number of entries in the color map. The default is ``None``,
609
609
in which case the number of entries is the sum of the
@@ -646,7 +646,7 @@ def join(self, other, name=None, frac_self=None, N=None):
646
646
647
647
__add__ = join
648
648
649
- def truncate (self , minval = 0.0 , maxval = 1.0 , N = None ):
649
+ def truncate (self , minval = 0.0 , maxval = 1.0 , name = None , N = None ):
650
650
"""
651
651
Truncate a colormap.
652
652
@@ -655,11 +655,12 @@ def truncate(self, minval=0.0, maxval=1.0, N=None):
655
655
minval : float in the interval ``(0.0, 1.0)``, optional
656
656
The lower fraction of the colormap you want to truncate
657
657
(default 0.0).
658
-
659
658
maxval : float in the interval ``(0.0, 1.0)``, optional
660
659
The upper limit of the colormap you want to keep. i.e. truncate
661
660
the section above this value (default 1.0).
662
-
661
+ name : str, optional
662
+ The name for the new truncated colormap. This defaults to
663
+ ``"trunc({},{:.2f},{:.2f})".format(self.name, minval, maxval)``
663
664
N : int
664
665
The number of entries in the map. The default is *None*,
665
666
in which case the same color-step density is preserved,
@@ -694,7 +695,8 @@ def truncate(self, minval=0.0, maxval=1.0, N=None):
694
695
# http://stackoverflow.com/a/18926541/2121597
695
696
if N is None :
696
697
N = np .ceil (self .N * (maxval - minval ))
697
- name = "trunc({},{:.2f},{:.2f})" .format (self .name , minval , maxval )
698
+ if name is None :
699
+ name = "trunc({},{:.2f},{:.2f})" .format (self .name , minval , maxval )
698
700
return ListedColormap (self (np .linspace (minval , maxval , N )), name )
699
701
700
702
0 commit comments