Hi,
I have this lying around:
def reverse_linearsegmentedcolormap(cmap):
"""Reverse a LinearSegmentedColormap
Parameters
----------
cmap : matplotlib.colors.Colormap
The colormap to be reversed.
Returns
-------
cmap_reversed : matplotlib.colors.Colormap
The colormap to be reversed.
"""
cdict = {}
for k, v in cmap._segmentdata.iteritems():
newlist = []
for c in v:
newlist.append((1.0 - c[0], c[1], c[2]))
v = newlist[::-1]
cdict[k] = v
cmap_reversed = deepcopy(cmap)
cmap_reversed._segmentdata = cdict
return cmap_reversed
Not sure at the moment why I'm writing LinearSegmentedColormap here;
this might be unnecessary.
Maybe it's helpful to someone ...
Cheers,
Andreas.
On 24.03.2015 14:30, Benjamin Root wrote:> Ah, indeed. I saw the "RdBu"
> <mailto:
scitools-iri...@googlegroups.com>.
> --
> You received this message because you are subscribed to the Google
> Groups "Iris" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
scitools-iri...@googlegroups.com
> <mailto:
scitools-iri...@googlegroups.com>.
--
-- Andreas.