《MATLAB SYNTAX》第10章 图形修饰

set(h,'propertyName',propertyValue); %设置图形句柄的属性
get(h,'propertyName'); %获取句柄为h的图形对象的propertyName的属性值
hp = get(h,'Parent'); %将h的父对象的句柄赋给hp
hc = get(h,'Children'); %将h的子对象的句柄赋给hc
h = gcf; %获取当前图形窗口的句柄
h = gca; %获取当前坐标轴的句柄

(10.1) 子图

subplot(m,n,p); %将图形窗口分成m×n个子绘图区,并按行优先从左到右编号,在第p个子图中绘图(逗号可以去掉)
subplot(m,n,[p1,p2]); %把第p1、第p2个子图合并

(10.2) 叠加图

hold on; %启动图形保持功能
hold off; %取消图形保持功能
hold; %在on和off之间进行切换

(10.3) 图形边框

box on; %给当前坐标轴添加边框
box off; %取消当前坐标轴的边框
box; %在on和off之间进行切换

(10.4) 图形网格线

grid on; %给当前坐标轴添加网格线
grid off; %取消当前坐标轴的网格线
grid; %在on和off之间进行切换
grid minor; %设置较小的网格线间距

(10.5) 坐标轴缩放

zoom on; %允许对坐标轴进行缩放
zoom off; %禁止对坐标轴进行缩放
zoom; %在on和off之间进行切换
zoom reset; %对当前的坐标轴进行复位,恢复到初始值
zoom xon; %允许对x轴进行缩放
zoom yon; %允许对y轴进行缩放

(10.6) 图形拖拽

pan on; %打开图形拖拽功能
pan off; %关闭图形拖拽功能
pan; %在on和off之间进行切换
pan xon; %打开图形在x轴方向的拖拽功能
pan yon; %打开图形在y轴方向的拖拽功能

(10.7) 颜色条

colorbar('Location'); %为图形添加颜色条并设置颜色条的位置(默认在图形外侧的右边)

(10.8) 图例

legend(string1,string2,...,'Location','locationString'); %添加图例,顺序给各个图形的描述
legend show; %开启图例,相当于legend on
legend hide; %隐藏图例,相当于legend off
legend boxon; %显示图例边框
legend boxoff; %隐藏图例边框
locationString含义locationString含义
best坐标区内最佳位置bestoutside坐标区外最佳位置
clc;clear;
x = linspace(0,pi,100);
y1 = cos(x);
y2 = cos(2*x);
y3 = cos(3*x);
y4 = cos(4*x);
plot(x,y1,x,y2,x,y3,x,y4);
h = legend({'cos(x)','cos(2x)','cos(3x)','cos(4x)'},'Location','best','NumColumns',2);
title(h,'My Legend Title');
legend boxoff;

在这里插入图片描述

(10.9) 图形文本标注

title(string); %给图形添加标题
xlabel(string); %设置x轴的名称
ylabel(string); %设置y轴的名称
zlabel(string); %设置z轴的名称
text(x,y,z,string); %(x,y,z)处添加文本
gtext(string); %通过鼠标点击的方式添加文本
set(gca,'XTick',[0,pi,2*pi],'XTickLabel',{'0','pi','2pi'}); %在横坐标的0、pi、2*pi三个点处设置该点的名称
set(gca,'YTick',[0,pi,2*pi],'YTickLabel',{'0','pi','2pi'}); %同上
set(gca,'ZTick',[0,pi,2*pi],'ZTickLabel',{'0','pi','2pi'});  %同上

(10.10) 坐标轴刻度范围

axis([xmin xmax ymin ymax zmin zmax cmin cmax]); %设置横、纵、竖、颜色坐标刻度范围
axis([thetamin thetamax rmin rmax]); %设置极坐标的极角和极径的刻度范围
xlim([xmin xmax]); %设置横坐标刻度范围
ylim([xmin xmax]); %设置纵坐标刻度范围
zlim([xmin xmax]); %设置竖坐标刻度范围
axis; %获取当前坐标刻度范围
axis on; %打开坐标轴的显示
axis off; %取消坐标轴的显示
axis ij; %使用矩阵式坐标,原点在左上方
axis xy; %使用直角坐标,原点在左下方
axis equal; %横、纵坐标采用等长刻度
axis tight; %把数据范围直接设置成坐标刻度范围
axis square; %产生正方形坐标系
axis normal; %解除对坐标轴的任何限制
axis auto; %使用坐标轴默认设置
axis manual; %保持当前坐标轴范围
axis fill; %使坐标充满整个绘图区(在manual方式下有效)
axis image; %横、纵坐标采用等长刻度,且坐标框紧贴数据范围

(10.11) 曲面亮度

brighten(value); %value在01之间增亮色图,-10之间变暗色图

(10.12) 曲面着色方式

clc;clear;
subplot(131)
peaks;
shading faceted;
title('faceted');
subplot(132)
peaks;
shading flat;
title('flat');
subplot(133)
peaks;
shading('interp');
title('interp');

在这里插入图片描述

(10.13) 曲面色彩

clc;clear;
%parula
figure('name','parula');
mesh(peaks);
colormap('parula');
%jet
figure('name','jet');
mesh(peaks);
colormap('jet');
%hsv
figure('name','hsv');
mesh(peaks);
colormap('hsv');
%hot
figure('name','hot');
mesh(peaks);
colormap('hot');
%cool
figure('name','cool');
mesh(peaks);
colormap('cool');
%spring
figure('name','spring');
mesh(peaks);
colormap('spring');
%summer
figure('name','summer');
mesh(peaks);
colormap('summer');
%autumn
figure('name','autumn');
mesh(peaks);
colormap('autumn');
%winter
figure('name','winter');
mesh(peaks);
colormap('winter');
%gray
figure('name','gray');
mesh(peaks);
colormap('gray');
%bone
figure('name','bone');
mesh(peaks);
colormap('bone');
%copper
figure('name','copper');
mesh(peaks);
colormap('copper');
%pink
figure('name','pink');
mesh(peaks);
colormap('pink');
%lines
figure('name','lines');
mesh(peaks);
colormap('lines');
%colorcube
figure('name','colorcube');
mesh(peaks);
colormap('colorcube');
%prism
figure('name','prism');
mesh(peaks);
colormap('prism');
%flag
figure('name','prism');
mesh(peaks);
colormap('flag');
%white
figure('name','white');
mesh(peaks);
colormap('white');

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

(10.14) 曲面透视

clc;clear;
subplot(121);
mesh(peaks);
hidden on;
subplot(122);
mesh(peaks);
hidden off;

在这里插入图片描述


《 M A T L A B   S Y N T A X 》 系 列 博 客 创 作 参 考 资 料 来 源 《MATLAB\ SYNTAX》系列博客创作参考资料来源 MATLAB SYNTAX

  1. 《自动控制原理实验教程》.巨林仓.西安交通大学出版社.
  2. 《MATLAB工程与科学绘图》.周博.薛世峰.清华大学出版社.
  3. 《MATLAB R2018a完全自学一本通》.刘浩.韩晶.电子工业出版社.
  4. 《科学计算与MATLAB语言》.刘卫国.蔡旭晖.吕格莉.何小贤.中国大学MOOC.
  5. 《MATLAB软件与基础数学实验》.李换琴.朱旭.王勇茂.籍万新.西安交通大学出版社.
  6. 《Matlab教程 - 图像处理》@正月点灯笼.https://www.bilibili.com.
  7. 《MATLAB从入门到秃头》@古德谓尔.https://www.bilibili.com.

博 客 创 作 : A i d e n   L e e 博客创作:Aiden\ Lee Aiden Lee
特别声明:文章仅供学习参考,转载请注明出处,严禁盗用!

  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值