阅读背景:

matlab学习随笔知识点合集

来源:互联网 
  • 图像对象和句柄

%% V. 图像对象和句柄
%%
% 1. 如何设置线条的属性呢?
x = 0:0.01:2*pi;
y = sin(x);
h = plot(x,y);
grid on
get(h)
set(h,'linestyle','-','linewidth',5,'color','k')

%%
% 2. 如何修改网格的间隔呢?  
set(gca,'xtick',0:0.5:7)%gca:get current axis 获得当前坐标轴
set(gca,'ytick',-1:0.1:1)

%%
% 3. 如何设置图例的字体及大小呢?
x = 0:0.01:2*pi;
y1 = sin(x);
y2 = cos(x);
plot(x,y1,'r')
hold on
plot(x,y2,'-.b')
h = legend('sin(x)','cos(x)');
set(h,'fontsize',16,'color','k','edgecolor','r','textcolor','w')

%%
% 4. 如何拆分图例呢?
x = 0:0.01:2*pi;
y1 = sin(x);
y2 = cos(x);
h1 = plot(x,y1,'r');
hold on
h2 = plot(x,y2,'-.b');
ax1 = axes('position',get(gca,'position'),'visible','off');
legend(ax1,h1,'sin(x)','location','northwest')
ax2 = axes('position',get(gca,'position'),'visible','off');
legend(ax2,h2,'cos(x)','location','northeast')
%% V. 图像对象和句柄
%



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: