Matlab 进阶绘图总结

一、对数图像绘制:

plot(x, y)        % 绘制普通图像

semilogx(x, y)        % 绘制以指数为刻度的 x 轴

semilogy(x, y)        % 绘制以指数为刻度的 y 轴

loglog(x, y)        % 绘制以指数为刻度的 x 轴与 y 轴

二、双 y 轴图像绘制(yyaxis):

注:matlab 官方建议使用 yyaxis 而不使用 plotyy

y = f(x)

z = g(x)

yyaxis left          % 绘制左侧 y 轴

plot(x,y)

...                       % 可以在此对左曲线参数进行一些修改

yyaxis right        % 绘制右侧 y 轴

plot(x,z)

...                       % 可以在此对右曲线参数进行一些修改

三、直方图绘制(histogram):

y =  randn(1,1000)

histogram(y, bins)        % 作出有 bins 个柱的直方图

四、条形统计图绘制(bar):

x = 1:2:10; y = [x, 1:5];

subplot(1, 3, 1); bar(x)

subplot(1, 3, 2); bar(y)

subplot(1, 3, 3); bar3(y)        % 三维条形图

 

subplot(1, 2, 1); bar(y, 'stacked')        % 堆叠展示

subplot(1, 2, 2); barh(y)                      % 水平展示

 五、饼状图:

x = [1, 2, 3, 4];

subplot(1, 3, 1); pie(x)

subplot(1, 3, 2); pie(x,[1,0,0,1])          % 第一块和第四块分离强调

subplot(1, 3, 3); pie3(x,[0,0,0,1])        % 三维饼状图

六、极坐标图:

theta = linspace(0, 2*pi, 7);        % 绘制六边形需要七个点,最后一个与第一个重合

r = ones(1, length(theta));

polar(theta, r)

七、阶梯图和离散序列:

x = linspace(0, 4*pi, 40); y = sin(x);

subplot(1, 3, 1); plot(y)

subplot(1, 3, 2); stairs(y)

subplot(1, 3, 3); stem(y)

 

八、填充封闭图形:

fill(x, y, 'color')        % 以某种颜色填充满图形 

九、三维图像绘制:

        在 matlab 中,其实并没有二维的图像,我们打开 工具—三维旋转 便会发现,所谓二维,只是将所有的值都展示在了同一个 xOy 平面上。

        方法一(plot3):

plot3(x, y, z, 'type')

        运用这种方法,能将几幅平面图展现在一副三维图中。

        方法二(surf):

x=-3.5:0.2:3.5;y=-3.5:0.2:3.5;

[X,Y]=meshgrid(x,y);

Z=X.*exp(-X.^2-Y.^2);

 subplot(1,2,1);mesh(X,Y,Z);axis square;        % 绘制网格曲面图

subplot(1,2,2);surf(X,Y,Z);axis square;         % 绘制曲面图

扁平化与等高线图:

subplot(1,2,1);imagesc(Z);axis square

subplot(1,2,2);contour(X,Y,Z);axis square

subplot(1,2,1);meshc(X,Y,Z);axis square;

subplot(1,2,2);surfc(X,Y,Z);axis square;

 

调整等高线图:

疏密度:

subplot(1,2,1);contour(X,Y,Z);axis square

subplot(1,2,2);contour(X,Y,Z,-.45:.05:.45);axis square

增加标度:

subplot(1,2,1);contour(X,Y,Z);axis square

subplot(1,2,2);[C,h]=contour(X,Y,Z);clabel(C,h);axis square;

涂色:

subplot(1,2,1);contour(X,Y,Z);axis square

subplot(1,2,2);contourf(X,Y,Z);axis square;

 

调出颜色板:

colorbar

 更改色系(内置):

colormap(hot)

colormap(cool)

 ...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

六月渔烬

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值