码迷,mamicode.com
首页 > 其他好文 > 详细

Matlab Plot 画图中图

时间:2014-09-13 09:24:14      阅读:643      评论:0      收藏:0      [点我收藏+]

标签:matlab   plot   

     用matlab 画图时,发现一部分范围内,线之间贴得太近。于是想在图中画另外一个小图,实现局部放大的功能。

     在网上众多偏方中,经过辛苦遴选与试验,发现以下的方法最为简单有效。

     废话不多说,2)关键代码; 1)效果。

%% ----- 1 效果:

bubuko.com,布布扣

         需要注意的是:小图的显示位置以及尺寸大小都是用代码来控制的,具体请研究如下区区20行代码。

%% ----- 2 Code:

figure
TextFontSize=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_1m
	plot(gamma, Avg_OPT_C, '-dk')
	hold on
	
	% --- 2 Avg-OPT_costs_2m
	plot(gamma, Avg_Greedy_C, '--sb')
	hold on

grid on

xlabel('\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 on	
	h42=plot(gamma2,Avg_Greedy_C2,'--sb');
% --- Plot the small one :~


Davy_H

2014-09-13

Matlab Plot 画图中图

标签:matlab   plot   

原文地址:http://blog.csdn.net/davyhwang/article/details/39248901

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!