How do I bind a specific value to a color using colormap?

I'm plotting a 2D contour plot using contourf(X, Y, Z). How can I create a custom colormap, where certain color would be bound to a curtain value? For example:

100 - [1 0 0] 200 - [1 0.5 0] 1000 - [1 1 0]

It would be also nice to make all values below 100, for example, [0.5 0 0] and all values above 1000 - [1 1 0.5].

Please, do not suggest colormap editor. If this task is impossible for colormap, suggest me another function for 2D plots (maybe, plot it dot by dot)

2 Comments
Walter Roberson on 16 Jan 2019

Direct link to this comment

Cancel Copy to Clipboard

Direct link to this comment

Cancel Copy to Clipboard

To confirm: if the input value were 100*(1+eps) then the output should be transparent because the value would not be any of the ones you listed?

Denis Perotto on 16 Jan 2019

Direct link to this comment

Cancel Copy to Clipboard

Direct link to this comment

Cancel Copy to Clipboard I meant non-even intervals: -inf . 100 - [0.5 0 0] 100-200 - [1 0 0] 200-1000 - [1 0.5 0] 1000 . inf - [1 1 0]

Accepted Answer

Walter Roberson on 16 Jan 2019

Direct link to this answer

Cancel Copy to Clipboard

Direct link to this answer

Cancel Copy to Clipboard
0 Comments

More Answers (1)

KSSV on 15 Jan 2019

Direct link to this answer

Cancel Copy to Clipboard

Direct link to this answer

Cancel Copy to Clipboard Refer this link for the same:
1 Comment
Denis Perotto on 16 Jan 2019

Direct link to this comment

Cancel Copy to Clipboard

Direct link to this comment

Cancel Copy to Clipboard Edited: Denis Perotto on 16 Jan 2019 Tricky, but not acceptable for me.

First, there is a need to see real, not modified, data at any point on a contour, when I move my mouse on that point.

Second, I anyway get an even distribution of colors, which I cannot control. I created a custom colormap of 8 colors and set up 8 intervals. But the cycle, which modifies data, sets all the values to the maximum, and I miss 1 color anyway. I tried to program it like this: