필터 지우기
필터 지우기

Auto generating x and y axis of same scale and labeling

조회 수: 8 (최근 30일)
MustangManiac
MustangManiac 2017년 12월 6일
답변: KL 2017년 12월 6일
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

답변 (1개)

KL
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'});

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by