How to make the axes equal

8 次查看(过去 30 天)
Eliska Paulikova
Eliska Paulikova 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 中查找有关 Graphics Object Programming 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by