How to only show part of a plot

조회 수: 97 (최근 30일)
Alex
Alex 2018년 3월 13일
편집: Adam Danz 2020년 1월 21일
I have a plot with an inset plot. For the inset plot I want the x-axis 'W' to show from 0 to 1, but I only want the y-axis 'tmp5' values from -0.5 to 0.5. How do I do this? Please refer to attached image file. Specifically I want the inset to clearly show that the line does not intersect the origin.
Cheers,
Alex
B_sat = 2.9901e+004;
B_gnd = 4.6750e+004;
W=0.0001:0.0001:1;%0.0001
for m=1:length(W)
Bw(m) = ((W(m)*B_sat) + ((1-W(m))*B_gnd));
end
tmp5 = (Bw - Bc);
fig=figure;
plot((ideal_int_sum - ideal_int_sum)./ideal_int_sum*100, alt,'--', (ideal_int_sum - Bavg_int_sum)./ideal_int_sum*100, alt, '-', (ideal_int_sum - Bw_int_sum)./ideal_int_sum*100, alt, '-','linewidth',5)%
hold on
plot((ideal_int_sum - Bc_int_sum)./ideal_int_sum*100, alt, '-. k', (ideal_int_sum -FRdipole_avg_t)./ideal_int_sum *100, alt, ':k','linewidth',3)%
set(gca,'layer','top','XMinorTick','on','YMinorTick','on')
set(gca,'fontsize',24, 'fontweight','bold')
hold off
xlabel('Percent difference from benchmark solution (%)','fontsize',24, 'fontweight','bold')
ylabel('Altitude (km)','fontsize',24, 'fontweight','bold');
legend('B_{IGRF}','B_{Avg}^A (w=0.5)', 'B_w (w=0.5209)', 'B_{calc} \propto FR/TEC', 'B_{Dipole}^{avg}', 'Location','northeast')
% create smaller axes in top right, and plot on it
axes('Position',[.7 .4 .2 .2])%[x-position from 0:1, y-position from 0:1, x-size from 0:1, y-size from 0:1]
box on
plot(W,tmp5)
grid on
xlabel('W');%,'fontsize',24, 'fontweight','bold');
ylabel('\Delta B');%,'fontsize',24, 'fontweight','bold');
orient(fig,'tall')
print(fig,'merged_comp_percent_difference.jpg','-djpeg')

채택된 답변

KSSV
KSSV 2018년 3월 13일
편집: KSSV 2018년 3월 13일
Read about axis, xlim and ylim
For your case try:
axis([0 1 -0.5 0.5])
  댓글 수: 1
Alex
Alex 2018년 3월 13일
Thank you! I used ylim([-05. 0.5]) since using xlim made the line look vertical.
Cheers,
Alex

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by