How can I delete an axes handle from a GUI?

So let me explain better. I have axes1 in my GUI and I have used 'scatter' to draw something in axes1. Now I want to remove the image and make axes1 non visible.
I tried to use set(handles.axes1,'Visible','Off') but this only makes axes not visible leaving there the scatter image.
I have also tried delete(handles.axes1) but this removes completely the handles from my GUI and I don't want that because the user may want to scatter a new graphic.
Sorry for my bad English and I hope I made myself clear...
Thanks!

 채택된 답변

Image Analyst
Image Analyst 2013년 3월 24일
편집: Image Analyst 2013년 3월 24일

1 개 추천

Unfortunately MATLAB is not like Microsoft Visual Studio in that regard. Setting the axes to invisible doesn't really hide the whole thing. Possibly the easiest way to do that is to place the axes inside a panel. Then you can set the panel visibility on or off and it will show or hide everything inside of it. Using cla() and it's various options will not hide the whole thing - you'll still have stuff showing. Hope that helps.

댓글 수: 4

Flávio
Flávio 2013년 3월 24일
Thanks man it really helps ;) I am trying to use cla() but you're right, I still have legend and a colorbar that don't disappear. Do you have any ideia how can I make them go away without using panel? (any specific function to close legends and colorbars perhaps?)
Image Analyst
Image Analyst 2013년 3월 24일
편집: Image Analyst 2013년 3월 24일
You'd have to use findobj() and figure out the handles of all the various parts and components of the axes, colorbar, and legend. Not easy. Then set all of those components' visibility on or off. A real hassle. Once the handles are found out, you can hard code them into a function and just call the function passing it on or off - makes it a little easier to use if you have to do it in serveral places in your code, or just to clean up / modularize your code to make it easier to read.
Flávio
Flávio 2013년 3월 24일
Thanks man! I will try it ;)
Flávio
Flávio 2013년 3월 24일
It's done. With legend I only wrote legend(handles.axes1,'off'). With colorbar I did like you said using findobj and it worked. Thanks ;)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by