필터 지우기
필터 지우기

Why do plotting commands delete axes UserData?

조회 수: 5 (최근 30일)
Bruce Elliott
Bruce Elliott 2020년 4월 16일
댓글: Steven Lord 2020년 4월 16일
If I store data in the UserData property of an open axes object and then plot something on the axes, the UserData is deleted. Does this happen for a good reason, and is there any way to prevent it?
Here is sample code to illustrate this:
>> myAx = axes;
>> myAx.UserData = 1:10;
>> myAx.UserData
ans =
1 2 3 4 5 6 7 8 9 10
>> plot(rand(5))
>> myAx.UserData
ans =
[]
I'd like to have UserData persist after adding more graphics objects to the axes.

채택된 답변

Bruce Elliott
Bruce Elliott 2020년 4월 16일
This was a silly question - I just need to call
>> hold on
before plotting. I knew that about graphics objects, but hadn't realized that all the axes properties are replaced by new plot commands.
  댓글 수: 1
Steven Lord
Steven Lord 2020년 4월 16일
Not all properties are reset. Units and Position keep their values.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by