How to delete a plot in UIAxes?

조회 수: 6 (최근 30일)
Eduardo Gaona Peña
Eduardo Gaona Peña 2017년 10월 2일
댓글: David J. Mack 2018년 2월 7일
I'm using a button as a tool to plot one linear fit over a curve and I would like to replace the plot of the fit whenever I push the button again. I'm not quite sure how to use the delete command in this case. Any help is appreciated :)

채택된 답변

David J. Mack
David J. Mack 2017년 10월 3일
편집: David J. Mack 2017년 10월 3일
You could store the handle to the fitted line in the UserData of the figure and then retrieve it every time the button is hit and use it to replace the YData of the line with the new fitted YData (this "replaces" the old line). Greetings, David
  댓글 수: 2
Jesus Velazquez
Jesus Velazquez 2018년 2월 1일
any chance you could share an example of this?
David J. Mack
David J. Mack 2018년 2월 7일
hFig = figure(); hPlot = plot(cfit); hFig.UserData.hPlot = hPlot; % Code to add the button
% in your callback hFig.UserData.hPlot.YData = newYData;

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by