For the final 3D surface output, I need to show a legend of two colors with X>breakpoint being blue and Y<breakpoint being green. I have been able to graph the two colored plot, but am having a hard time figuring out how to split up the legend according to my breakpoint.
I have been using the colormap tool but have not been successful as it is still not using my defined breakpoint. The colors need to be two defined regions with no shading.
surf(xa,ya,Profile,'EdgeColor','none')
breakpoint = 1;
colors = [0 0 1; 0 1 1];
colormap(colors);
colorbar
One way to get an only 2 colors surface is to use the
Color
argument of thesurf(...)
function.You can build a color matrix
ColorData
, the same size as your data, with only 2 values:Then if you plot the surface with the color argument specified, and apply a 2 colors colormap, all the levels are going to adjust themselves.
However, if we leave it like that the colorbar ticks are now invalid, they go from 0 to 1 instead of showing the full range of data. It's ok though, you can create a set of meaningful labels and overide the default one.
In code it looks like (Thank you Wolfie for the demo data) :
The result for
breakpoint=1
andbreakpoint=1.75
are shown below:The downside of that method is that on the colorbar the breakpoint is always going to sit in the middle of the colorbar, even if your actual breakpoint is closer to the lower or upper boundary of your data values.