Axis position is shifted when YtickLabel gets different number of digits in App designer.

조회 수: 1 (최근 30일)
I made an axis to plot a spectrum on App designer. When data of spectrum was changed and the YtickLabel gets different number of digits, the position of the Y axis was shifted as shown in the attached figure. Is there any way to prevent the shift without turning off auto y axis range, and without normalization of the spectrum data?

채택된 답변

亮介 桶谷
亮介 桶谷 2021년 6월 29일
After reading Bjorn Gustavsson's comment, I got a hint from his comment and found a good way to solve the problem.
I just put
app.axis.InnerPosition = [46.4000 53.4000 436.1000 156.6000];
after I did "plot".
Thank you for the advice from Bjorn Gustavsson!!

추가 답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 6월 29일
The cumbersome way of explicitly aligning the the position of the axes after each plotting might work? Something like this perhaps:
indefinite = 123; % just for illustratino
for i1 = 1:indefinite
x = randn(321,1);
y = rand(321,1);
t = 0:321;
sph1 = subplot(2,1,1); % more modern means exist
plot(t,y)
sph2 = subplot(2,1,2);
plot(t,x)
pos1 = get(sph1,'position');
pos2 = get(sph2,'position');
set(pos2,'position',[pos1(1),pos2(2),pos1(3),pos2(4)])
drawnow
end
That should force the axeses to line up in the vertical direction.
HTH
  댓글 수: 2
亮介 桶谷
亮介 桶谷 2021년 6월 29일
Thank you for your comment!
Actually, your answer didnot work on app designer.
But I got a hint from your comment and found a good way to solve the problem!!!
I just put
app.axis.InnerPosition = [46.4000 53.4000 436.1000 156.6000];
after I did "plot".
Thank you for your advice!!
Bjorn Gustavsson
Bjorn Gustavsson 2021년 6월 29일
Good. I haven't worked with app designer - but there ought to be a similar handle-graphics interface to the plottings, so now you now roughly what to look for and where...

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

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by