- leave hold on throughout the app, so you're always adding to the axes.
- Store the Polygon objects that you're plotting in properties too: define properties that correspond to pg and ps here, and then capture those when you call plot.
- Instead of relying on the hold off, manually delete the Polygon objects when you enter your callback.
How to do the check box in GUI app designer ??
8 views (last 30 days)
when I check on the box I got the wanted results , hovever, when I remove the check I get an error message rather than the original shape.
value = app.DegreeCheckBox.Value;
x = roi.Position;
x_val = x(:,1);
y_val = x(:,2);
polygon = polyshape(x_val, y_val);
if app.DegreeCheckBox.Value == 1
pg = plot(app.UIAxes, polygon, 'FaceColor', '#4DBEEE', 'FaceAlpha', 0.8);
hold (app.UIAxes, 'on');
poly3 = rotate(polygon, 45);
ps = plot(app.UIAxes, poly3, 'FaceColor','#FF00FF','FaceAlpha', 0.8 );
axis (app.UIAxes, 'tight', 'equal');
Dave B on 4 Dec 2021
You should not use global, roi should probably be a property on your app.
But I think to prevent it from being deleted, you need to alter your plot code...I suspect that calling hold on and hold off is the issue here: when hold is off the first plot command replaces everything in your axes including the rois. So I think you need a strategy that says 'keep the rois' and 'delete the Polygons'
There are a few options here, I think my strategy would probably be to: