How to only show part of a plot

99 次查看(过去 30 天)
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