Clear Filters
Clear Filters

How can I adjust a matrix or a color map to have a gradient plus two distinct colors?

2 views (last 30 days)
I have some data that ranges from 0 to 1 inclusive. This data is on the even positions (i.e., row and column both even) of a matrix, with -1 values on the other positions. What I'd like to do is plot the matrix with imagesc, and have the -1 positions be black, the data that is exactly zero be shown in gray, and then the data >0 to be in a gradient from white to red, for example. I have made my own color map and tried adding values for black and gray at the end and adjusting the cmap range, but it seems like there's rounding going on that makes small but non-zero values of the data come out gray. Is there an easier way to do this, or is there a good explanation of how to separate distinct colors of a colormap by data?
Thanks!

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!