Delete rectangles drawn in figure axes
조회 수: 27 (최근 30일)
이전 댓글 표시
Hi there,
i try to delete all rectangles drawn into a figure axes. When creating these Rectangles, they're saved to a struct which is present in the function where i want to delete the existing rectangles. How can i detect all objects of the type Rectangle, or is there a different way to gett all drawn rectangles in an figure axes?
I added a screenshot of the figure axes with one rectangle drawn in there in red:
![2019-07-03 17_09_52-Ask a Question - MATLAB Answers - MATLAB Central – Opera.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227316/2019-07-03%2017_09_52-Ask%20a%20Question%20-%20MATLAB%20Answers%20-%20MATLAB%20Central%20%E2%80%93%20Opera.png)
Im using Win 10 with Matlab R2019a.
Thanks a lot in advance.
Best
Valentin
댓글 수: 0
답변 (1개)
Harsha Priya Daggubati
2019년 7월 17일
Hi,
You can get all the Graphics Objects of the preferred type present in MATLAB figure using ‘findall’ function in MATLAB and then delete all the objects using ‘delete’ function in MATLAB.
For instance, try executing this code:
figure;
axis([0 10 0 10]);
rectangle(‘Position’,[1 2 5 6]);
rect = findall(gcf,’Type', 'Rectangle’);
delete(rect);
Refer to this documentation links:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!