I have a 3d function and want to show contours at [0.683 0.9545 0.9973]. I want the area 0->0.683 to be filled with red, 0.683->0.9545 to be blue, 0.9545->0.9973 to be green and 0.9973->1.0 to be white.
So basically I have the following:
contours = [0.0 0.683 0.9545 0.9973 1.0]
contourf(x,y,z,contours)
and tried
colormap([1 0 0; 0 0 1; 0 1 0; 1 1 1])
but it's not right. Please, what should my colormap look like in order to get the colours I want?
At a guess, I would say that you need to have an amount of rows per color proportional to the size of each range. So
0->0.683is a lot bigger than0.683->0.9545. In your color map you have provided only one row each so Matlab assumes that those colors should be assigned equally over the full range (i.e.0->1) which with 4 colors means that red is for0->0.25, blue is for0.25->0.5etc...Try something like this answer: How to create a custom colormap programmatically? but instead of using
linspace, userepmat. You'll need to have enough rows to account for your 4 decimal point precision (which you might want to rethink) so in total you'll have 10 000 rows:or alternatively: