How to only show part of a plot

99 ビュー (過去 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 Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by