分享兴趣,传播快乐,
增长见闻,留下美好。
亲爱的您,这里是LearningYard学苑!
今天小编为大家带来Matlab绘制图的介绍第四期。
欢迎您的访问!
本期阅读时长大约为5分钟,请您耐心阅读。
Share interest, spread happiness,
increase knowledge, and leave beautiful.
Dear, this is the LearingYard Academy!
Today, the editor brings the “introduction of
Matlab plotting” Part Ⅳ.
Welcome to visit!
This tweet usually takes about 5 minutes to read,
please be patient and read.
思维导图 Mind mapping
内容摘要 Abstract
1. 绘制三维柱状图 Plotting 3D bar chart
bar3(Z) 绘制三维条形图,Z 中的每个元素对应一个条形图。如果 Z 是向量,y 轴的刻度范围是从 1 至 length(Z)。如果 Z 是矩阵,则 y 轴的刻度范围是从 1 到 Z 的行数。具体代码如下:
bar3(z) creates a 3-D bar graph for the elements of z. Each bar corresponds to an element in z. If z is a matrix, elements from the same row in z appear at the same location along the y-axis. The code is as follow:
x=1:5;
y=6:10;
z=x.*y;
[X,Y]=meshgrid(x,y);
Z=X.*Y;
subplot(2,2,1);
bar3(x,y);
subplot(2,2,2);
bar3(Z);
subplot(2,2,3);
bar3(Z,'grouped');
subplot(2,2,4);
bar3(Z,'stacked');
2. 绘制三维饼图 Plotting 3D pie chart
pie3(X) 使用 X 中的数据绘制三维饼图。X 中的每个元素表示饼图中的一个扇区。需要注意的是:
如果 sum(X) ≤ 1,X 中的值直接指定饼图切片的面积。如果 sum(X) < 1,pie3 仅绘制部分饼图。
如果 X 中元素的总和大于一,则 pie3 会通过 X/sum(X) 将值归一化,以确定饼图每个扇区的面积。
pie3(X) draws a three-dimensional pie chart using the data in X. Each element in X is represented as a slice in the pie chart.
If sum(X) ≤ 1, then the values in X directly specify the area of the pie slices. pie3 draws only a partial pie if sum(X) < 1.
If the sum of the elements in X is greater than one, then pie3 normalizes the values by X/sum(X) to determine the area of each slice of the pie.
具体代码如下:
The code is as follow:
x=1:5;
y=6:10;
z=x.*y;
pie3(z);
title('三维饼状图')
3. 绘制三维散点图 Plotting 3D scatter chart
scatter3(X,Y,Z) 在向量 X、Y 和 Z 指定的位置显示圆圈。scatter3(___,'filled') 使用前面的语法中的任何输入参数组合填充这些圆。
scatter3(X,Y,Z) displays circles at the locations specified by X, Y, and Z. scatter3(___,'filled') fills in the circles, using any of the input argument combinations in the previous syntaxes.
具体代码如下:
The code is as follow:
x=-10:0.1:10;
y=sin(x);
z=exp(x);
subplot(1,2,1);
scatter3(x,y,z);
subplot(1,2,2);
scatter3(x,y,z,'filled')
图像从上面看是正弦函数,从正面看是指数函数。
The image is a sinusoidal function when viewed from above and an exponential function when viewed from the front.
4. 绘制三维隐函数图 Plotting 3D fimplicit chart
fimplicit(f) 在默认区间 [-5 5](对于 x 和 y)上绘制 f(x,y) = 0 定义的隐函数。具体代码如下:
fimplicit3(f) plots the 3-D implicit function defined by f(x,y,z) = 0 over the default interval [-5 5] for x, y, and z. The code is as follow:
f=@(x,y,z)x.^2 y.^2-z;
fimplicit3(f);
colormap('jet')
今天的分享就到这里了。
如果您对今天的文章有独特的想法,
欢迎给我们留言,
让我们相约明天。
祝您今天过得开心快乐!
That's all for today's sharing.
If you have a unique idea about the article,
please leave us a message,
and let us meet tomorrow.
I wish you a nice day!
参考资料:Bilibili、Matlab帮助中心、DeepL翻译
本文由LearningYard学苑原创,如有侵权请在后台留言!
LearningYard学苑
文字|Young
排版|Young
审核|Zheng