Reverse colormap in matplotlib

前端 未结 7 792
小蘑菇
小蘑菇 2020-11-28 02:04

I would like to know how to simply reverse the color order of a given colormap in order to use it with plot_surface.

7条回答
  •  失恋的感觉
    2020-11-28 03:03

    As of Matplotlib 2.0, there is a reversed() method for ListedColormap and LinearSegmentedColorMap objects, so you can just do

    cmap_reversed = cmap.reversed()

    Here is the documentation.

提交回复
热议问题