MATLAB 的 plot 绘图

文章目录

  • Syntax
  • Description
      • plot(X,Y)
      • plot(X,Y,LineSpec)
      • plot(X1,Y1,…,Xn,Yn)
      • plot(X1,Y1,LineSpec1,...,Xn,Yn,LineSpecn)
      • plot(Y)
      • plot(Y,LineSpec)
      • plot(tbl,xvar,yvar)
      • plot(tbl,yvar)
      • plot(ax,___)
      • plot(___,Name,Value)
      • p = plot(___)

plot: 2-D line plot

Syntax

  1. plot(X,Y)
  2. plot(X,Y,LineSpec)
  3. plot(X1,Y1,…,Xn,Yn)
  4. plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn)
  5. plot(Y)
  6. plot(Y,LineSpec)
  7. plot(tbl,xvar,yvar)
  8. plot(tbl,yvar)
  9. plot(ax,___)
  10. plot(___,Name,Value)
  11. p = plot(___)

Description

plot(X,Y)

plot(X,Y) creates a 2-D line plot of the data in Y versus the corresponding values in X.

  1. To plot a set of coordinates connected by line segments, specify X and Y as vectors of the same length. (要绘制由线段连接的一组坐标,指定X和Y为相同长度的向量。)
  2. To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix. (若要在同一组轴上绘制多组坐标,请将X或Y中的至少一个指定为矩阵。)

plot(X,Y,LineSpec)

plot(X,Y,LineSpec) creates the plot using the specified line style, marker, and color.

plot(X1,Y1,…,Xn,Yn)

plot(X1,Y1,…,Xn,Yn) plots multiple pairs of x- and y-coordinates on the same set of axes. Use this syntax as an alternative to specifying coordinates as matrices. (使用此语法作为将坐标指定为矩阵的替代方法。)

plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn)

plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn) assigns specific line styles, markers, and colors to each x-y pair. You can specify LineSpec for some x-y pairs and omit it for others. For example, plot(X1,Y1,“o”,X2,Y2) specifies markers for the first x-y pair but not for the second pair.

plot(Y)

plot(Y) plots Y against an implicit set of x-coordinates. (plot(Y)根据一组隐式的x坐标绘制Y。)

  1. If Y is a vector, the x-coordinates range from 1 to length(Y).
  2. If Y is a matrix, the plot contains one line for each column in Y. The x-coordinates range from 1 to the number of rows in Y. (如果Y是一个矩阵, 那么Y的每一列都会绘制出一条线, x坐标从1递增至Y的行数。)

If Y contains complex numbers, MATLAB® plots the imaginary part of Y versus the real part of Y. If you specify both X and Y, the imaginary part is ignored. (如果Y包含复数,MATLAB®绘制Y的虚部与Y的实部。如果同时指定X和Y,则忽略虚部。)

plot(Y,LineSpec)

plot(Y,LineSpec) plots Y using implicit x-coordinates, and specifies the line style, marker, and color.

plot(tbl,xvar,yvar)

plot(tbl,xvar,yvar) plots the variables xvar and yvar from the table tbl. To plot one data set, specify one variable for xvar and one variable for yvar. To plot multiple data sets, specify multiple variables for xvar, yvar, or both. If both arguments specify multiple variables, they must specify the same number of variables. (since R2022a) (Plot (tbl,xvar,yvar) 绘制表tbl中的变量xvar和yvar。要绘制一个数据集,请分别为xvar和yvar指定一个变量。若要绘制多个数据集,请为xvar、yvar或两者指定多个变量。如果两个参数都指定了多个变量,它们必须指定相同数量的变量。(自从R2022a))

plot(tbl,yvar)

plot(tbl,yvar) plots the specified variable from the table against the row indices of the table. If the table is a timetable, the specified variable is plotted against the row times of the timetable. (since R2022a) (Plot (tbl,yvar) 根据表的行索引绘制表中的指定变量。如果表是时间表,则根据时间表的行时间绘制指定变量。(自从R2022a))

plot(ax,___)

plot(ax,___) displays the plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes. (Plot (ax,___) 在指定的坐标轴上绘图。将坐标轴指定为第一个参数。)

plot(___,Name,Value)

plot(___,Name,Value) specifies Line properties using one or more name-value arguments. The properties apply to all the plotted lines. Specify the name-value arguments after all the arguments in any of the previous syntaxes. For a list of properties, see Line Properties. (plot(___,Name,Value) 使用一个或多个名称-值参数指定线条属性。这些属性适用于所有绘制的线条。在所有参数之后指定名称-值参数。有关属性列表,请参见线条属性。)

p = plot(___)

p = plot(___) returns a Line object or an array of Line objects. Use p to modify properties of the plot after creating it. For a list of properties, see Line Properties. (p = plot(___) 返回一个Line对象或一个Line对象数组。使用p在创建绘图后修改其属性。)

Vector and Matrix Data Table Data Additional Options
plot(X,Y) plot(tbl,xvar,yvar) plot(ax,___)
plot(X,Y,LineSpec) plot(tbl,yvar) plot(___,Name,Value)
plot(X1,Y1,…,Xn,Yn) p = plot(___)
plot(X1,Y1,LineSpec1,…,Xn,Yn,LineSpecn)
plot(Y)
plot(Y,LineSpec)

你可能感兴趣的:(MATLAB,matlab)