When drawing with MATLAB, it is found that the line is too close within a part of the range. So I want to draw another small image in the figure to implement the local zoom-in function.
Among the many online remedies, after hard selection and tests, we found that the following methods are the most simple and effective.
Not much nonsense, 2) key code; 1) effect.
% ----- 1 effect:
Note that the position and size of a thumbnail are controlled by Code. For details, see the following code for 20 lines.
% ----- 2 code:
figureTextFontSize=20;LegendFontSize = 18;% ------------- Plot the big one : -------------set(0,'DefaultAxesFontName','Times',... 'DefaultLineLineWidth',1,... 'DefaultLineMarkerSize',8);set(gca,'FontName','Times New Roman','FontSize',TextFontSize);set(gcf,'Units','inches','Position',[0 0 6.0 4.0]);% --- 1 Avg-OPT_costs_1mplot(gamma, Avg_OPT_C, '-dk')hold on% --- 2 Avg-OPT_costs_2mplot(gamma, Avg_Greedy_C, '--sb')hold ongrid onxlabel('\gamma')ylabel('Cost')hg1 = legend('Offline OPT', 'Offline Greedy',1);set(hg1,'FontSize',LegendFontSize);% --- Plot the big one :~% ------------- Plot the small one : -------------set(0,'DefaultTextFontName','Times',... 'DefaultAxesFontName','Times',... 'DefaultLineLineWidth',1,... 'DefaultLineMarkerSize',4);h1=axes('position',[0.42 0.26 0.45 0.44]);set(h1,'FontName','Times New Roman','FontSize',16);axis(h1);xlim([0 0.25]);h41=plot(gamma2,Avg_OPT_C2,'-dk');hold onh42=plot(gamma2,Avg_Greedy_C2,'--sb');% --- Plot the small one :~
Davy_h
2014-09-13
MATLAB plot Graph