matlab 绘图2

绘图2

clc,clear;
close all;
x=linspace(0,2*pi,100);
plot(x,sin(x),'r',x,2*sin(x),'g',x,3*sin(x),'b')

result
在这里插入图片描述

clc,clear;
close all;
x=linspace(0,2*pi,100);
plot(x,sin(x),'r',x,2*sin(x),'g',x,3*sin(x),'b')
axis tight;

result
在这里插入图片描述

% x轴 
x = 0:1/3000:1; 
% 生成误差曲线 
y = cos(tan(pi*x)); 
% 绘图 
figure 
% 分裂窗口为3行一列的3个子窗口 
subplot(3,1,1) 
plot(x,y) 
title('\itcos(tan(\pix))') 
% 坐标轴调整 
subplot(3,1,2) 
plot(x,y) 
axis([0.45 0.55 -1 1]); 
title('复杂函数的局部透视') 
subplot(3,1,3) 
plot(x,y) 
axis([0.49 0.51 -1 1]); 
title('复杂函数的深入局部透视') 

在这里插入图片描述

semilogx函数使用半对数坐标,x轴为常用对数刻度,而y轴仍保持线性刻度。semilogy恰好和semilogx相反。
loglog函数使用全对数坐标,x、y轴均采用对数刻度。

clc,clear;
close all;
% x轴 
x=0:0.5:5; 
% y轴 
y = exp(x); 
% 绘图 
figure 
% 笛卡尔坐标系 
subplot(4, 1, 1) 
plot(x, y, 'r.') 
title('笛卡尔坐标系') 
% 半对数坐标系 
subplot(4, 1, 2) 
semilogx(x, y, 'g+') 
title('x轴为对数坐标系') 
subplot(4, 1, 3) 
semilogy(x, y, 'b-') 
title('y轴为对数坐标系') 
% 对数坐标系 
subplot(4, 1, 4) 
loglog(x, y, 'ms','LineWidth',4) 
title('对数坐标系')

result
在这里插入图片描述

clc,clear;
close all;
X = 1:3;
labels = {'Taxes','Expenses','Profit'};
explode = {'Profit'};
p = pie(X,labels)
t = p(6);
t.BackgroundColor = 'c';
t.EdgeColor = 'm';
t.FontSize = 14;
t = p(4);
t.BackgroundColor = 'g';
t.EdgeColor = 'm';
t.FontSize = 14;
t = p(2);
t.BackgroundColor = 'r';
t.EdgeColor = 'm';
t.FontSize = 14;

result
在这里插入图片描述

clc,clear;
close all;
x=[160 33 45 42 45]; 
% 分离显示设置 
explode=[1 1 1 1 1]; 
% 绘图 
figure() 
cm=[0 1 0; 1 0 0; [122 16 228]/255; 0 0 1;0 1 1];
colormap(cm);
%colormap hsv 
pie(x,explode,{'alimony','information costs','correspondence/telephone bill','clothes costs','others'}) 
title('饼图') 

result
在这里插入图片描述

clc,clear;
close all;
%随机函数产生5*3的数组,对产生的数据取整 
Y = round(rand(5,3)*10);  
% 绘图 
subplot(2,2,1) 
bar(Y,'group') 
title '分组二维垂直条形图' 
%堆型二维垂直条形图 
subplot(2,2,2) 
bar(Y,'stack') 
title('堆型二维垂直条形图') 
%堆型二维水平条形图 
subplot(2,2,3) 
barh(Y,'stack') 
title('堆型二维水平条形图') 
%设定条形的宽度为1.5 
subplot(2,2,4) 
bar(Y,1.5) 
title('重叠二维水平条形图') 

result
在这里插入图片描述

clc,clear;
close all;
% 数据准备 
y=[190 33 45 42 45]; 
x=1:5;
figure 
bar(x,y) 
title('柱状图'); 
set(gca,'xTicklabel',{'alimony','info','tele','clothes','others'})

result
在这里插入图片描述
累计分布

clc,clear;
close all;
pies = {'Chocolate','Apple','Pecan','Cherry','Pumpkin'};
votes = [35 50 30 5 80];
pareto(votes,pies,1)
ylabel('Votes')

在这里插入图片描述

clc,clear;
close all;

t=0:pi/50:2*pi;
x=8*cos(t);
y=16*sqrt(2)*sin(t);
z=16*sqrt(2)*sin(t);
plot3(x,y,z,'p');
title('三维空间闭合曲线(笛卡尔坐标系)');
text(0,0,0,'ori');
xlabel('X');
ylabel('Y');
zlabel('Z');
grid;

result
在这里插入图片描述

clc,clear;
close all;

% 数据准备 
t=0:pi/10:pi; 
x=sin(t); 
y=cos(t);  
[X,Y]=meshgrid(x,y); 
z =X + Y;    

figure 
mesh (z,'FaceColor','r','EdgeColor','y')
grid 
title('三维袈裟'); 

在这里插入图片描述

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值