Auto generating x and y axis of same scale and labeling
11 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/167331/image.png)
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 个评论
回答(1 个)
KL
2017-12-6
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!