@@ -659,6 +659,12 @@ def is_gray(self):
659659 return (np .alltrue (self ._lut [:, 0 ] == self ._lut [:, 1 ]) and
660660 np .alltrue (self ._lut [:, 0 ] == self ._lut [:, 2 ]))
661661
662+ def _resample (self , lutsize ):
663+ """
664+ Return a new color map with *lutsize* entries.
665+ """
666+ raise NotImplementedError ()
667+
662668
663669class LinearSegmentedColormap (Colormap ):
664670 """Colormap objects based on lookup tables using linear segments.
@@ -772,6 +778,12 @@ def from_list(name, colors, N=256, gamma=1.0):
772778
773779 return LinearSegmentedColormap (name , cdict , N , gamma )
774780
781+ def _resample (self , lutsize ):
782+ """
783+ Return a new color map with *lutsize* entries.
784+ """
785+ return LinearSegmentedColormap (self .name , self ._segmentdata , lutsize )
786+
775787
776788class ListedColormap (Colormap ):
777789 """Colormap object generated from a list of colors.
@@ -836,6 +848,12 @@ def _init(self):
836848 self ._isinit = True
837849 self ._set_extremes ()
838850
851+ def _resample (self , lutsize ):
852+ """
853+ Return a new color map with *lutsize* entries.
854+ """
855+ return ListedColormap (self .name , self .colors , lutsize )
856+
839857
840858class Normalize (object ):
841859 """
0 commit comments