Whiteout/Remove some part of the contour plot
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Muhammad Usman
le 7 Nov 2019
0 votes
8 commentaires
Robert U
le 7 Nov 2019
contourf fills the space between gridpoints. I assume the space between a grid point with value and gridpoint without value will not be filled as well.
You can observe in your initially posted figures, that the boundary between results and zero-assigned values is not correct as well, since colormap interpolates from gridpoint value to zero which leaves you a rainbow-like contour-line outside of your ellipse.
In order to correct the issue you could snap the displayed ellipse to valid gridpoints (which will probably increase the ellipse area).
If it's just for optical reason: you can either reduce the size of your ellipse for the logical expressions by one gridpoint in each direction or assign synthetic values. Before applying any measure like this, make sure they make sense on your data.
Muhammad Usman
le 7 Nov 2019
Robert U
le 7 Nov 2019
If so, you might consider to provide a finer mesh.
Muhammad Usman
le 7 Nov 2019
Robert U
le 7 Nov 2019
As far as I understood, you are exporting your FEM node results to Matlab. There, you apply scatteredInterpolant in order to map your original data on a (equidistant) grid that is easy to plot.
You should have a look whether your ellipse is matching the used grid for plotting. I am quite sure that this is not the case since you used an analytical description of the ellipse and plotted it overlaying the contourf plot.
The result grid for plotting could be chosen finer in order to have smaller deviation from FEM grid near the ellipse.
Muhammad Usman
le 7 Nov 2019
Tamas Lanci
le 3 Avr 2020
Is there any chance you can share your code Muhammad?
Muhammad Usman
le 13 Avr 2020
Modifié(e) : Muhammad Usman
le 13 Avr 2020
Catégories
En savoir plus sur 2-D and 3-D 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!


