简体   繁体   中英

Brushing data on plot linked with 2D variable

I have a 2D numeric array (100x100 double) which looks like this when plotted on a surf plot:

I am trying to link the plot with the variable, and then delete some data points (say, one of the two peaks) both in the variable (make the selected points 0) and in the plot, by using the brush tool on the plot.

The problem is, when the variable and the plot are linked, the brushing tool selects the full rows for the points that fall on the selected area, as shown here:

Selection when data is linked (I want to avoid this type of selection):

Same selection, data not linked (this is what I want, but with linked data):

Is there any way to avoid this, and select only the points that I want?

Details about this phenomenon can be found here: https://uk.mathworks.com/help/matlab/ref/matlab.graphics.interaction.internal.brush.html#mw_b080675e-afd3-4251-99d8-a8273e85dc6c

I have also tried using other types of plots (mesh, sky, etc), but I could not find any solutions.

As a minimal reproducible example, you can use the following code:

PeaksVariable = peaks;
surf(PeaksVariable)
linkdata on
brush on

You can get the brushed data points with

PeaksVariable = peaks;
brush on;
s = surf( PeaksVariable );
b = logical( s.BrushData );

Then set the brushed points to whatever value you want

PeaksVariable( b ) = NaN;

And optionally update the surface with the updated data variable

s.ZData = PeaksVariable;

拉丝

移除

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