matlab-画图函数:scatter和plot

由于需要画图的时候会经常忘记画图函数的具体参数,所以给总结了一下,便于自己和大家用的时候查起来方便,不用到处查,浪费很多时间。

画图的时候常用的画图函数有scatter和plot,具体语法可以直接在MATLAB命令框里输入:help+空格+函数名,查看具体的语法规则,还附带例子的,比网上查的更清楚,也更全面。

具体的图形的表示方法:

颜色:

'yellow'            'y',黄色
'magenta' 'm',洋红
'cyan'         'c',青色
'red'                 'r',红色
'green'         'g',绿色
'blue'         'b',蓝色
'white'         'w',白色
'black'         'k',黑色

形状:

'o' Circle,圆形
'+' Plus sign,加号
'*' Asterisk,星号
'.' Point,点
'x' Cross,X
'square' or 's' Square,方形
'diamond' or 'd' Diamond,菱形
'^' Upward-pointing triangle,向上的箭头
'v' Downward-pointing triangle,向下的箭头
'>' Right-pointing triangle,向右的箭头
'<' Left-pointing triangle,向左的箭头
'pentagram' or 'p' Five-pointed star (pentagram),五角星
'hexagram' or 'h' Six-pointed star (hexagram),六角星

注意:如果是'none',则表示No markers,没有任何标记。

scatter函数的语法:

扫描二维码关注公众号,回复: 2745108 查看本文章

(1)scatter(x,y):creates a scatter plot with circles at the locations specified by the vectors x and y. This type of graph is also known as a bubble plot.

(2)scatter(x,y,sz):specifies the circle sizes. To plot each circle with equal size, specify sz as a scalar. To plot each circle with a different size, specify sz as a vector with length equal to the length of x and y.

(3)scatter(x,y,sz,c):specifies the circle colors. To plot all circles with the same color, specify c as a color name or an RGB triplet. To use varying color, specify c as a vector or a three-column matrix of RGB triplets.

(4)scatter(___,'filled'):fills in the circles. Use the 'filled' option with any of the input argument combinations in the previous syntaxes.

(5)scatter(___,mkr):specifies the marker type.

(6)scatter(___,Name,Value):specifies scatter series properties using one or more Name,Value pair arguments. For example, 'LineWidth',2 sets the marker outline width to 2 points.

(7)scatter(ax,___):plots into the axes specified by ax instead of into the current axes. The option ax can precede any of the input argument combinations in the previous syntaxes.

(8)s = scatter(___):returns the scatter series object. Use s to make future modifications to the scatter series after it is created.

plot函数的语法:

(1)plot(X,Y):creates a 2-D line plot of the data in Y versus the corresponding values in X.
· If X and Y are both vectors, then they must have equal length. The plot function plots Y versus X.
· If X and Y are both matrices, then they must have equal size. The plot function plots columns of Y versus columns of X.
· If one of X or Y is a vector and the other is a matrix, then the matrix must have dimensions such that one of its dimensions equals the vector length. If the number of matrix rows equals the vector length, then the plot function plots each matrix column versus the vector. If the number of matrix columns equals the vector length, then the function plots each matrix row versus the vector. If the matrix is square, then the function plots each column versus the vector.

· If one of X or Y is a scalar and the other is either a scalar or a vector, then the plot function plots discrete points. However, to see the points you must specify a marker symbol, for example, plot(X,Y,'o').

(2)plot(X,Y,LineSpec):sets the line style, marker symbol, and color.

(3)plot(X1,Y1,...,Xn,Yn):plots multiple X, Y pairs using the same axes for all lines.

(4)plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn):sets the line style, marker type, and color for each line. You can mix X, Y, LineSpec triplets with X, Y pairs. For example, plot(X1,Y1,X2,Y2,LineSpec2,X3,Y3).

(5)plot(Y) creates a 2-D line plot of the data in Y versus the index of each value.
· If Y is a vector, then the x-axis scale ranges from 1 to length(Y).
· If Y is a matrix, then the plot function plots the columns of Y versus their row number. The x-axis scale ranges from 1 to the number of rows in Y.

· If Y is complex, then the plot function plots the imaginary part of Y versus the real part of Y, such that plot(Y) is equivalent to plot(real(Y),imag(Y)).

(6)plot(Y,LineSpec):sets the line style, marker symbol, and color.

 (7) plot(___,Name,Value):specifies line properties using one or more Name,Value pair arguments. For a list of properties, see Chart Line Properties. Use this option with any of the input argument combinations in the previous syntaxes. Name,Value pair settings apply to all the lines plotted.

(8)plot(ax,___):creates the line in the axes specified by ax instead of in the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes.

(9)h = plot(___):returns a column vector of chart line objects. Use h to modify properties of a specific chart line after it is created. For a list of properties, see Chart Line Properties.

【感谢您的支持,打赏随意】

猜你喜欢

转载自blog.csdn.net/Ryan_lee9410/article/details/80494921