玖叶教程网

前端编程开发入门

文学文享(11):Matlab绘图学习之x/ylabel和图像属性

分享兴趣,传播快乐,增长见闻,留下美好。

亲爱的您,这里是LearningYard学苑!

今天小编为大家带来Matlab绘图学习分享。

欢迎您的访问!

Share interest, spread happiness, increase knowledge, and leave beautiful.

Dear, this is the LearingYard Academy!

Today, the editor brings the Matlab drawing learning and sharing.

Welcome to visit!

1 内容摘要(Content summary)

本文将分享小编学习Matlab绘图的过程,本次学习的是Matlab绘图中xlabel函数、ylabel函数和图像的颜色、线型、标记等属性。

This article will share the editor's process of learning Matlab drawing. This time, we will learn about the xlabel function, ylabel function and the color, line type, mark and other attributes of the image in Matlab drawing.

2 思维导图(Mind mapping)

3 正文(Text)

3.1 xlabel和ylabel(xlabel and ylabel)

xlabel函数和ylabel函数的作用相似,可以分别为图像的x轴和y轴添加标签,本次将放在一起进行学习。

The xlabel function and the ylabel function have similar functions. They can add labels to the x-axis and y-axis of the image respectively. This time they will be put together for learning.

(1) xlabel(txt) / ylabel(txt)

此语法会对当前坐标区或独立可视化的x轴/y轴添加标签。

This syntax adds labels to the current axes or the x-axis/y-axis of a standalone visualization.

(2) xlabel(target,txt) / ylabel(target,txt)

若同一张画布中存在多张图像,使用此语法则可将标签添加到指定图像的x轴或y轴上。

If there are multiple images in the same canvas, use this syntax to add labels to the x-axis or y-axis of the specified image.

(3) xlabel( ,Name,Value) / ylabel( ,Name,Value)

此语法的作用是使用多个名称-值对组参数来修改标签的外观,需要在所有其他输入参数之后进行外观的设置。

The effect of this syntax is to use multiple name-value pair parameters to modify the appearance of the label, and the appearance needs to be set after all other input parameters.

图中FontWeight的作用是设置字体的粗细,normal表示正常,bold为加粗。

The function of FontWeight in the figure is to set the thickness of the font, normal means normal, and bold means bold.

(4) t=xlabel( ) / t=ylabel( )

此语法的作用是返回用作x轴或y轴标签的文本对象。

What this syntax does is return the text object used as the x-axis or y-axis label.

之后使用t加圆点便可对标签文本的属性进行修改。

Then use t to add a dot to modify the attributes of the label text.

3.2 图像属性(Image properties)

在同一坐标区进行绘图时,Matlab会为每条线条赋予不同的颜色,以进行区分。若简单的颜色区分不足以满足实际需求,则可通过一些代码来更改线条的颜色或线型。

When plotting in the same coordinate area, Matlab assigns different colors to each line for distinction. If the simple color distinction is not enough to meet the actual needs, some codes can be used to change the color or line type of the line.

3.2.1 颜色(Color)

Matlab提供了8种可供用户设置的颜色,在绘图时可以通过颜色名称、短名称、RGB三元组等方式来指定图像的颜色。

Matlab provides 8 colors that can be set by the user, and the color of the image can be specified by color name, short name, RGB triplet, etc. when drawing.

若用户不进行自定义设置,Matlab会为图像赋予软件自带的颜色。

If the user does not make custom settings, Matlab will give the image the color that comes with the software.

(1) 指定条形图的颜色

(1) Specify the color of the bar graph

绘制一张条形图,并为图像设置红色。

Draw a bar chart and set the red color for the image.

使用b返回条件对象的作用是方便后续使用b加圆点对图像的属性进行修改。

The function of using b to return the condition object is to facilitate the subsequent use of b plus a dot to modify the properties of the image.

(2) 指定散点图中标记颜色

(2) Specify the marker color in the scatter plot

使用scatter函数绘制一张散点图,指定圆点的大小为30磅,填充颜色青绿色,轮廓颜色品红色。

Use the scatter function to draw a scatterplot, specify the size of the dots to be 30 points, the fill color is turquoise, and the outline color is magenta.

(3) 指定一系列绘图中的颜色

(3) Specify the colors in a series of plots

若同一坐标系中有多条不同的线条,则可使用返回条件对象的方式对其中某条的属性进行修改。

If there are multiple different lines in the same coordinate system, the property of one of them can be modified by returning the condition object.

3.2.2 线型和标记(Line type and mark)

Matlab提供了多种线型和标记类型供用户选择,想要绘制出具有特色的图形就可以尝试使用这些线型和标记。

Matlab provides a variety of line types and marker types for users to choose. If you want to draw characteristic graphics, you can try to use these line types and markers.

线型和标记的用法相似,使用代表不同线型和标记的符号即可对图像属性进行修改。

Linetypes and markers are used similarly, and image properties can be modified using symbols representing different linetypes and markers.

创建一张虚线线图,可以使用绘图函数自带的linespec区域,也可以使用返回条件对象的方式。

To create a dotted line graph, you can use the linespec area that comes with the drawing function, or you can use the method of returning a condition object.

再为虚线图的数据点添加星号标记。

Then add asterisk marks to the data points of the dashed line graph.

3.2.3 属性组合(Attribute combination)

有时需要绘制指定颜色、线型和标记的图像,此时可以将属性的组合置于绘图函数的linespec区域,一步到位,绘制出想要的图形。

Sometimes it is necessary to draw images with specified colors, line types and markers. At this time, you can put the combination of attributes in the linespec area of the drawing function, and draw the desired graphics in one step.

其中“--”表示虚线,“o”表示数据点使用圆形标记,“m”表示使用品红色绘制图像。

Where "--" indicates a dashed line, "o" indicates that the data points are marked using circles, and "m" indicates that the image is plotted using magenta.

同样可以使用返回条件对象的方式进行属性设置。

You can also use the method of returning the condition object to set the property.

今天的分享就到这里了。

如果您对今天的文章有独特的想法,

欢迎给我们留言,

让我们相约明天。

祝您今天过得开心快乐!

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!


参考资料:

翻译:

Google翻译

文字:

https://ww2.mathworks.cn/?s_tid=gn_logo

图片:

自制

版权说明:

本文由LearningYard学苑整理并发出,如有侵权请后台留言沟通。


文案I姜疯雨火

排版I姜疯雨火

审核IGoldfish

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言