Effacer les filtres
Effacer les filtres

How to make the axes equal

5 vues (au cours des 30 derniers jours)
Eliska Paulikova
Eliska Paulikova le 7 Mar 2023
Commenté : Dyuman Joshi le 7 Mar 2023
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 commentaires
Eliska Paulikova
Eliska Paulikova le 7 Mar 2023
They dont, that is the problem, I would like to make the axes fix from 0 to 24
Dyuman Joshi
Dyuman Joshi le 7 Mar 2023
%Either manually define the limits in xlim and ylim
xlim([0 24])
ylim([0 24])
%or use axis
axis([0 24 0 24])

Connectez-vous pour commenter.

Réponses (1)

Arka
Arka le 7 Mar 2023
Modifié(e) : Arka le 7 Mar 2023
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.

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Tags

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by