2

I want to use the 'terrain' colormap but I want it to start at the green colors and not de blues. How can I do that?

Specifically, how can I change a colormap to start at another color of the same colormap??.

I have this:

import matplotlib.pyplot as plt

levels = [0,100,250,500,800,1250,1600,2000,2500,3000,4000,5000]
palette = plt.get_cmap('terrain')

fig, ax = plt.subplots()
C = ax.contourf(lon, lat, hgt,
                cmap = paleta,
                extend='max',
                levels=levels)

cbar=plt.colorbar(C,ticks=levels,spacing='proportional')
cbar.set_label('m',fontsize=18)
cbar.ax.yaxis.set_ticklabels(levels,fontsize=18)

Any suggestions? Thank you very much

Martín
  • 21
  • 2
  • 2
    Does this answer your question? [how to extract a subset of a colormap as a new colormap in matplotlib?](https://stackoverflow.com/questions/18926031/how-to-extract-a-subset-of-a-colormap-as-a-new-colormap-in-matplotlib) – bglbrt Dec 05 '19 at 16:30
  • Please also see the docs: https://matplotlib.org/3.1.1/tutorials/colors/colormap-manipulation.html – Jody Klymak Dec 05 '19 at 17:06

0 Answers0