How to clear data from plot in Matlab GUI

 採用された回答

Image Analyst
Image Analyst 2013 年 8 月 14 日
編集済み: Image Analyst 2013 年 8 月 14 日

26 投票

Perhaps try this:
axes(handles.averSpec); % Make averSpec the current axes.
cla reset; % Do a complete and total reset of the axes.
If you want to clear just the curve, bars, surfaces, or whatever you plotted, and not the labels, tick spacing etc., then get the handle to it when you created it and then delete it
hPlotData = plot(....... whatever
% Now get rid of it.
delete(hPlotData);

7 件のコメント

Jonasz
Jonasz 2013 年 8 月 14 日
I don't know but it didn't work.
Jhonantans Rocha
Jhonantans Rocha 2014 年 8 月 25 日
Man, it really helped me! Thanks!
Image Analyst
Image Analyst 2014 年 8 月 26 日
You're welcome. Can you go ahead and mark my Answer as "Accepted" then?
Robert
Robert 2016 年 4 月 9 日
This worked for me.
Christopher A. De Oliveira
Christopher A. De Oliveira 2019 年 7 月 9 日
thanks man you saves the world
Hunter Pruett
Hunter Pruett 2020 年 5 月 23 日
awesome, thanks so much!
Yassir Amhot
Yassir Amhot 2020 年 12 月 4 日
Holy crap, thank you sooo much

サインインしてコメントする。

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 14 日

2 投票

You can use cla

5 件のコメント

Jonasz
Jonasz 2013 年 8 月 14 日
編集済み: Azzi Abdelmalek 2013 年 8 月 14 日
I am using and nothing ..
function clear_Callback(hObject, eventdata, handles)
% hObject handle to clear (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla(handles.averSpec);
This is starting when you press ' clear' button
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 14 日
Is there any error message ?
Jonasz
Jonasz 2013 年 8 月 14 日
No but nothing happen plot stays the same.
Martin Castillo Yañez
Martin Castillo Yañez 2016 年 10 月 17 日
same issue
Image Analyst
Image Analyst 2016 年 10 月 18 日
If you tried my answer of using
cla reset;
and that did not wipe the axes totally clean, down to a white rectangle with axes in the 0-1 range, then call the Mathworks because your cla function is corrupted. Or you've overwritten it with your own function called cla.

サインインしてコメントする。

David Sanchez
David Sanchez 2013 年 8 月 14 日

0 投票

Try with
clf(handles.my_axis_handle)
where my_axis_handle is the handle of the axis on your GUI.

2 件のコメント

Jonasz
Jonasz 2013 年 8 月 14 日
It clear all the figure except my axis I want to clear. But i want to clear the data not the whole axis.
Robert
Robert 2016 年 4 月 9 日
This is exactly what happened to me. When i used this line it cleared everything except what i wanted it to clear. When i type in the handle of the axes i want to clear that is the only one it left alone and cleared the rest of the guy. Any ideas?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

製品

質問済み:

2013 年 8 月 14 日

コメント済み:

2020 年 12 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by