Auto generating x and y axis of same scale and labeling
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I'm currently generating a series of subplots using the following code below. When it generates a plot I get a nice subplot but the axis are different scales and have different labeling. For example the y axis is from 23 to 27.5, and the x-axis is from 24 to 26.5.
*Is there a way to automatically generate axis that are the exact same length scale and labeling? I could hard code it but my data changes each time so that's not very useful.*
if true
figure('Position',[100 75 1400 900]);
hold on
subplot(2,3,1)
plot(dat.ca90,(cyl1.theta1090+cyl2.theta1090+cyl3.theta1090+cyl4.theta1090)/4,'o','MarkerFaceColor',cc(ic,:),'MarkerEdgeColor',cc(ic,:),'LineWidth',2,'MarkerSize',4); hold on;
xlabel('Dyno','FontSize',12);
ylabel('Sim', 'FontSize',12);
Min = min(dat.ca90);
Max = max(dat.ca90);
plot([Min,Max],[Min,Max],'b');
plot([Min,Max],[Min-2,Max-2],'r--');
plot([Min,Max],[Min+2,Max+2],'r--');
grid on
t = title('CA1090 (CAD)');
set(t,'FontSize',12);
end
0 commentaires
Réponses (1)
KL
le 6 Déc 2017
Define it once with an axis handle and then use linkprop to link all your xlim, ylim properties,
figure
ax1 = subplot(2,1,1)
plot(1:10)
ax1.XLim = [-10 10];
ax2.YLim = [-10 10];
ax2 = subplot(2,1,2)
plot(10:-1:-10)
finally link,
hlink = linkprop([ax1,ax2],{'XLim','YLim'});
0 commentaires
Voir également
Catégories
En savoir plus sur Axis Labels dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!