How to make the axes equal
6 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
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
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)])
ytick=([0 round(25/0.145)*1/3 round(25/0.145)*2/3 round(24/0.145)])
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!