How to only show part of a plot

65 Ansichten (letzte 30 Tage)
Alex
Alex am 13 Mär. 2018
Bearbeitet: Adam Danz am 21 Jan. 2020
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')

Akzeptierte Antwort

KSSV
KSSV am 13 Mär. 2018
Bearbeitet: KSSV am 13 Mär. 2018
Read about axis, xlim and ylim
For your case try:
axis([0 1 -0.5 0.5])
  1 Kommentar
Alex
Alex am 13 Mär. 2018
Thank you! I used ylim([-05. 0.5]) since using xlim made the line look vertical.
Cheers,
Alex

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by