필터 지우기
필터 지우기

Can hgtransform be Used with a Constant Line Object?

조회 수: 3 (최근 30일)
Paul
Paul 2024년 4월 20일
답변: Paras Gupta 2024년 5월 1일
This code runs fine on my machine with 2022a. Generates an error here with 2024a. Didn't see anything in the release notes to suggest that setting the parent of a Constant Line to a Transform should no longer work.
rng(100)
figure;scatter(randn(100,1),randn(100,1))
theta = 30;
h = xline(0);
t = hgtransform('Parent',gca);
set(h,'Parent',t);
Error using matlab.graphics.chart.decoration.ConstantLine/setParentImpl
Parent must be a Cartesian axes.
set(t,'Matrix',makehgtform('zrotate',-theta*pi/180));
axis([-10 10 -10 10])

채택된 답변

Paras Gupta
Paras Gupta 2024년 5월 1일
Hey Paul,
The parent of the 'ConstantLine' should be an 'axes' object, as specified in the the following documentation under 'Parent/Child' property for MATLAB R2024a.
Since the following code snippet returns false, the error in the question seems to be expected as the 'hgtransform' object is not a Cartesian Axes object.
t = hgtransform('Parent',gca);
isa(t, 'matlab.graphics.axis.Axes')
ans = logical
0
The error also seems to occur in MATLAB R2023a and R2023b. The below documentation of 'ConstantLine' for MATLAB R2022a also suggests that its parent should be an 'axes' object, so the error occuring in later releases might be the result of a bug fix.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by