How to make the axes equal

조회 수: 6 (최근 30일)
Eliska Paulikova
Eliska Paulikova 2023년 3월 7일
댓글: Dyuman Joshi 2023년 3월 7일
axes_x = htabulka(:,1);
axes_y = htabulka(:,2);
plot(axes_x, axes_y)
Dolx=Sp(:,1)-82.5;
Dopx=Sp(:,1)+82.5;
Doly=Sp(:,2)-82.5;
Dopy=Sp(:,2)+82.5;
xlim([Dolx Dopx])
ylim([Doly Dopy])
xtick=([Dolx Dopx])
ytick=([Doly Dopy])
conversion=0.145; % in mm/pixel
addMM=@(x) sprintf('%.f mm',x*conversion);
xticklabels(cellfun(addMM,num2cell(xticks'),'UniformOutput',false));
yticklabels(cellfun(addMM,num2cell(yticks'),'UniformOutput',false));
Hello, I have this code, which works perfect for me, but it gives me the axes, which is not equal, I would like to make the axes from 0 to 24, but as you can see, it is not perfekt.
  댓글 수: 3
Eliska Paulikova
Eliska Paulikova 2023년 3월 7일
They dont, that is the problem, I would like to make the axes fix from 0 to 24
Dyuman Joshi
Dyuman Joshi 2023년 3월 7일
%Either manually define the limits in xlim and ylim
xlim([0 24])
ylim([0 24])
%or use axis
axis([0 24 0 24])

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

답변 (1개)

Arka
Arka 2023년 3월 7일
편집: Arka 2023년 3월 7일
Hi,
Since I do not have access to the variables htabulka and Sp, I cannot run the MATLAB code on my end.
I used a custom dataset to generate the plot.
theta = linspace(0, 2*pi, 100);
axes_x = cos(theta)*round(1/0.145)+4/0.145;
axes_y = sin(theta)*round(1/0.145)+4/0.145;
plot(axes_x, axes_y)
%xlim([0 round(25/0.145)])
%ylim([0 round(25/0.145)])
xtick=([0 round(25/0.145)*1/3 round(25/0.145)*2/3 round(24/0.145)])
xtick = 1×4
0 57.3333 114.6667 166.0000
ytick=([0 round(25/0.145)*1/3 round(25/0.145)*2/3 round(24/0.145)])
ytick = 1×4
0 57.3333 114.6667 166.0000
conversion=0.145; % in mm/pixel
addMM=@(x) sprintf('%.f mm',x*conversion);
xticklabels(cellfun(addMM,num2cell(xtick'),'UniformOutput',false));
yticklabels(cellfun(addMM,num2cell(ytick'),'UniformOutput',false));
Hope this is what you were looking for.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by