How to assign a colour to particular value and rest of the values have their standard colours

5 views (last 30 days)
Hello ,
1.I want to assign a white colour to zero value and other than zeroth value (even the value just greater than zero. ex: 0.001,0.0001 ) should carry a colour which should represent their magnitude. I have created the plot by using contourf(x,y,z) by creating the meshgrid. The problem is, it is taking same colour to all the values which are almost equal to zero.
2. I also want to hide the axis values in meshgrid and also making the graph to exactly fit to the meshgrid.
Kindly help me. .
Thanks in advance.

Answers (1)

Cris LaPierre
Cris LaPierre on 6 Mar 2021
One solution I can think of is to replace all zeros with NaN. In a contour plot, NaNs display as white.
Z=meshgrid(-0.1:0.001:0.1);
% normal
contourf(Z)
% Change 0s to NaN
figure
Z(Z==0)=nan;
contourf(Z)

Categories

Find more on Contour Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!