How to color the matlab plot -
is there exist way color plot in matlab? example x , y coordinate between 0 , 1. want give red zone area x times y less 0.5 , yellow rest.
thank you.
you can use pcolor generate pseudocolor-plot. values of x*y appropriate matrix-multiplication m. m can compared 0.5 m<0.5. returns logical-matrix converted double double-function , passed pcolor. set colormap containing red , yellow. can apply shading flat or shading interp (additionally interpolates), lines between patches disappear.
x = linspace(0,1,1000); y = x; m = x'*y; pcolor(x,y,double(m<0.5)); colormap([1,1,0;1,0,0]); shading interp this result: 
edit: if want several areas different colors, add new color colormap , edit color-argument of pcolor accordingly. following code generates three-zone plot:
x = linspace(0,1,1000); y = x; m = x'*y; c = double(m<0.5)+double(m<0.75); pcolor(x,y,c); colormap([0,1,0;1,1,0;1,0,0]); shading flat the result looks this: 
Comments
Post a Comment