Whiteout regions on Contour Plot
Afficher commentaires plus anciens
I don't want to display certain regions of the contour plot. How can I whiteout these regions on the contour plot? The interpolated data fills the entire space while the real data has blank regions that physically don't contain anything. These blank regions are the regions that I don't want to display on the contour plot. I have attached the two plots.
I have the scatter plot data as x,y,z arrays and the interpolated data for the contour plot as x,y,z matrices.
Any help/suggestion is welcomed and appreciated. Thank you.

Réponse acceptée
Plus de réponses (1)
Muhammad Usman
le 6 Nov 2019
0 votes
I have got the same problem but mine was a little bit simple. I use the built-in MATLAB function "scatterInterpolant" to plot a contour. The plot is shown below.

It's s stress contour and the ellipse is an empty space and there are no nodes inside the ellipse. I want the ellipse to be whiteout. Somehow I managed to set the values inside the ellipse to be zero (because I can't delete them) and I got the following result
I want the ellipse to be whiteout. Any sort of help is highly appreciated. Thanks in advance.P.S. I use the fill command to fill the ellipse with white color but that's not a proper way to do it.
8 commentaires
Walter Roberson
le 6 Nov 2019
You can set the values to nan in the ellipse instead of zero. If you specifically need white in that area, then the easiest way might be to use nan there but put a white patch behind that will show through where there are nan.
Muhammad Usman
le 6 Nov 2019
Thank you very much sir. NaN worked.
Supreeth M
le 11 Août 2020
How to put a white patch behind?
Walter Roberson
le 11 Août 2020
If anything is 3d then patch() with z coordinate lower than any used value. Otherwise, if you are using 2d only, fill() and use uistack to put it behind the other objects.
TAN SAK JIE
le 6 Jan 2021
Sir...may I know what is the method that you are using to find the data inside the eclipse and set the value into NaN at your second picture?
TAN SAK JIE
le 6 Jan 2021
I have the similar problem that only have the outer boundary for the ellipse same as the picture one..
Jiandong
le 31 Mar 2023
Maybe you can use the inpolygon function
[in,on] = inpolygon(x_list,y_list,ellipse_x,ellipse_y);
for i = 1:length(x_list)
if(in(i))
ellipse_x(i)=NaN;
ellipse_y(i)=NaN;
end
end
Walter Roberson
le 31 Mar 2023
That suggests to me that you could use the shorter
[in,on] = inpolygon(x_list,y_list,ellipse_x,ellipse_y);
ellipse_x(in) = NaN;
ellipse_y(in) = NaN;
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!