简体   繁体   中英

Matplotlib heatmap with one color

I'm trying to generate a heatmap like this one .

I would like to have only one color, going from white where values are smaller to some other color when values are higher.

I tried setting cmap to one color, but the final result is still a map where I can see different colors (blue, red, etc..).

How can I do that? Also, do the values need to be within a specific range?

Give a color map to the cmap argument of imshow . Eg

from matplotlib.pyplot import cm
imshow(A, interpolation='nearest', cmap=cm.Blues)

Color map samples: http://matplotlib.org/examples/color/colormaps_reference.html

By default, the lowest and highest data values are mapped to the ends of the color range. You can override this behavior by using the arguments vmin and vmax (or norm ) of imshow .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM