简体   繁体   中英

How to outline a region in a surface plot in Matlab

I have a 2D array data and I plot it using surf . In the surface plot, there is a region in which the elements in data are greater than 0.9*max(max(data)) . I want to 'outline' the region. How can I do that?

If I type

data_copy = data;
data_copy(data<0.9) = nan;

Then if I use scatter plot together with the original surface plot to plot the coordinates of data_copy that are not nan, I can 'shade' the region. But I just want the 'boundary' of the region. How to do that?

I am not sure, that this is exactly what you want, but you can try the following: consider a simple example - f(x,y)=sin(2 pi x) . You can remove edges from your plot (if you have a lot of data, it looks messy). Then, you can explicitly set the colors: draw the region of interest with one color, and all the other data with other:

data=repmat(sin(2*pi*(0:0.01:1)),numel(0:0.01:1),1); %define data
s=surf(data) % plot
s.EdgeAlpha=0; % remove edges
s.CData(data>=0.9*max(max(data)))=0; %set the color for the region of interest
s.CData(data<0.9*max(max(data)))=1; %set different color for all other data

Now it is clear, where your boundary is.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM