matlab绘制二维曲线,如何设置线型、颜色、标记点类型、如何设置坐标轴、matlab 图表标注、在图中标记想要的点

matlab绘制二维曲线,如何设置线型、颜色、标记点类型、如何设置坐标轴、matlab 图表如何标注、如何在图中标记想要的点

matlab绘制二维曲线,如何在图中标记想要的点。。。如何设置线型、颜色、标记点类型。。。如何设置坐标轴。。。matlab 图表标注操作。。。

在MATLAB中,可以使用plot函数绘制图形,并使用text函数在图中标记想要的点。

例1:如何在图中标记一个点:

% 创建一个示例图形
x = linspace(0,10,100);
y = sin(x);
figure
plot(x, y);
hold on;% 在图中标记一个点
x_point = 5;
y_point = sin(x_point);
% plot(x_point, y_point, 'ro');%红色 o 标记
% plot(x_point, y_point, 'r.', 'MarkerSize',12);% 指定标记样式、颜色、大小
% plot(x_point, y_point, 'Color','red', 'Marker','.', 'MarkerSize',12);
plot(x_point, y_point, 'r*');%红色 * 标记
text(x_point, y_point, 'Point');% 设置图形标题和坐标轴标签
title('示例图');
xlabel('X轴');
ylabel('Y轴');% 关闭图形保持功能
hold off;

例2:绘制曲线-创建后修改线

将x定义为−2π和2π之间的100个线性间隔值。将y1和y2定义为x的正弦和余弦值。创建两组数据的折线图,并画出曲线。

x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
figure
p = plot(x,y1,x,y2);

将第一行的线宽更改为2。将星形标记添加到第二行。使用点表示法设置特性。

x = linspace(-2*pi,2*pi);
y1 = sin(x);
y2 = cos(x);
figure
p = plot(x,y1,x,y2);
p(1).LineWidth = 2;
p(2).Marker = '*';

例3:指定绘制曲线的样式

绘制三条正弦曲线,每条线之间有一个小的相移。对第一条线使用默认的线样式。为第二条线指定虚线样式,为第三条线指定点线样式。

x = 0:pi/100:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);figure
plot(x,y1,x,y2,'--',x,y3,':')

例4:指定线条样式、颜色和标记

x = 0:pi/100:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);figure
plot(x,y1,x,y2,'--',x,y3,':')

例5:在特定数据点显示标记

x = linspace(0,10);
y = sin(x);
plot(x,y,'-o','MarkerIndices',1:5:length(y))

例6:指定线宽、标记大小和标记颜色

x = -pi:pi/10:pi;
y = tan(sin(x)) - sin(tan(x));figure
plot(x,y,'--gs',...'LineWidth',2,...'MarkerSize',10,...'MarkerEdgeColor','b',...'MarkerFaceColor',[0.5,0.5,0.5])

例7:添加标题和轴标签

x = linspace(0,10,150);
y = cos(5*x);
figure
plot(x,y,'Color',[0,0.7,0.9])
title('2-D Line Plot')
xlabel('x')
ylabel('cos(5x)')

x = 0:0.1:2*pi; y1 = sin(x); y2 = exp(-x);
plot(x, y1, '--*', x, y2, ':o');
xlabel('t = 0 to 2\pi');% 添加X轴标签
ylabel('values of sin(t) and e^{-x}')% 添加Y轴标签
title('Function Plots of sin(t) and e^{-x}');% 添加图表标题
legend('sin(t)','e^{-x}');% 添加图例

例8:绘制工期和指定刻度格式

t = 0:seconds(30):minutes(3);
y = rand(1,7);
figure
plot(t,y,'DurationTickFormat','mm:ss')

例9:从表中打印坐标

tbl = readtimetable("weather.csv");
tbl = sortrows(tbl);
head(tbl,3)
p = plot(tbl,"RainInchesPerMinute");

tbl = readtimetable("weather.csv");
tbl = sortrows(tbl);
head(tbl,3)
p = plot(tbl,"RainInchesPerMinute");
p.LineStyle = ":";
p.Color = "red";
p.Marker = ".";

例10:在一个轴上绘制多个图表,并添加图例

tbl = readtimetable("weather.csv");
head(tbl,3)

添加图例。请注意,图例标签与变量名称匹配。

plot(tbl,["Temperature" "PressureHg"])
legend

x=0:0.5:4*pi;
y=sin(x); h=cos(x); w=1./(1+exp(-x)); g=(1/(2*pi*2)^0.5).*exp((-1.*(x-2*pi).^2)./(2*2^2));
plot(x,y,'bd-' ,x,h,'gp:',x,w,'ro-' ,x,g,'c^-');        % 绘制多条图线
legend('sin(x)','cos(x)','Sigmoid','Gauss function');    % 添加图例

例11:指定直线打印的轴

        可以使用tiledlayout和nexttile函数显示绘图的平铺。调用tiledlayout函数来创建一个2乘1的平铺图表布局。调用nexttile函数来创建一个axs对象,并将该对象返回为ax1。通过将ax1传递给绘图函数来创建顶部绘图。通过将轴传递给title和ylabel函数,将title和y轴标签添加到绘图中。重复该过程以创建底部绘图。

% Create data and 2-by-1 tiled chart layout
x = linspace(0,3);
y1 = sin(5*x);
y2 = sin(15*x);
tiledlayout(2,1)% Top plot
ax1 = nexttile;
plot(ax1,x,y1)
title(ax1,'Top Plot')
ylabel(ax1,'sin(5x)')% Bottom plot
ax2 = nexttile;
plot(ax2,x,y2)
title(ax2,'Bottom Plot')
ylabel(ax2,'sin(15x)')

例12:给图表添加注释

x = linspace(0,3); y = x.^2.*sin(x); plot(x,y);
line([2,2],[0,2^2*sin(2)]);
str = '$$ \int_{0}^{2} x^2\sin(x) dx $$';
text(0.25,2.5,str,'Interpreter','latex');% 向数据点添加文本说明
annotation('arrow','X',[0.32,0.5],'Y',[0.6,0.4]);% 创建注释

plot()函数

2-D line plot

图线的绘制与装饰

plot(x,y,LineSpec)

参数说明:

  • x : 图线上点的x坐标
  • y : 图线上点的y坐标
  • LineSpec : 图线的线条设定,三个指定 线型 , 标记符号 和 颜色 的 设定符 组成一个字符串,设定符不区分先后.具体细节请参考 官方文档 .

语法:

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(___)

参数说明:

Vector and Matrix Data

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

  • To plot a set of coordinates connected by line segments, specify X and Y as vectors of the same length.

  • To plot multiple sets of coordinates on the same set of axes, specify at least one of X or Y as a matrix.

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

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) 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) plots Y against an implicit set of x-coordinates.

  • If Y is a vector, the x-coordinates range from 1 to length(Y).

  • 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.

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.

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

Table Data

  1. 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 xvaryvar, or both. If both arguments specify multiple variables, they must specify the same number of variables. (since R2022a)
  2. 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)

Additional Options

  1. plot(ax,___) displays the plot in the target axes. Specify the axes as the first argument in any of the previous syntaxes.
  2. 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.
  3. 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.

设置线型、标记点样式、颜色:

LineSpec — Line style, marker, and color
string scalar | character vector

Line style, marker, and color, specified as a string scalar or character vector containing symbols. The symbols can appear in any order. You do not need to specify all three characteristics (line style, marker, and color). For example, if you omit the line style and specify the marker, then the plot shows only the marker and no line.

Example: "--or" is a red dashed line with circle markers.

Line StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

MarkerDescriptionResulting Marker
"o"Circle

Sample of circle marker

"+"Plus sign

Sample of plus sign marker

"*"Asterisk

Sample of asterisk marker

"."Point

Sample of point marker

"x"Cross

Sample of cross marker

"_"Horizontal line

Sample of horizontal line marker

"|"Vertical line

Sample of vertical line marker

"square"Square

Sample of square marker

"diamond"Diamond

Sample of diamond marker

"^"Upward-pointing triangle

Sample of upward-pointing triangle marker

"v"Downward-pointing triangle

Sample of downward-pointing triangle marker

">"Right-pointing triangle

Sample of right-pointing triangle marker

"<"Left-pointing triangle

Sample of left-pointing triangle marker

"pentagram"Pentagram

Sample of pentagram marker

"hexagram"Hexagram

Sample of hexagram marker

Color NameShort NameRGB TripletAppearance
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan""c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

tbl — Source table
table | timetable

Source table containing the data to plot, specified as a table or a timetable.

xvar — Table variables containing x-coordinates
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()

Table variables containing the x-coordinates, specified using one of the indexing schemes from the table.

Indexing SchemeExamples

Variable names:

  • A string, character vector, or cell array.

  • A pattern object.

  • "A" or 'A' — A variable named A

  • ["A","B"] or {'A','B'} — Two variables named A and B

  • "Var"+digitsPattern(1) — Variables named "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A vector of numbers.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [2 3] — The second and third variables from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects variables of a specified type.

  • vartype("categorical") — All the variables containing categorical values

The table variables you specify can contain numeric, categorical, datetime, or duration values. If xvar and yvar both specify multiple variables, the number of variables must be the same.

Example: plot(tbl,["x1","x2"],"y") specifies the table variables named x1 and x2 for the x-coordinates.

Example: plot(tbl,2,"y") specifies the second variable for the x-coordinates.

Example: plot(tbl,vartype("numeric"),"y") specifies all numeric variables for the x-coordinates.

yvar — Table variables containing y-coordinates
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()

Table variables containing the y-coordinates, specified using one of the indexing schemes from the table.

Indexing SchemeExamples

Variable names:

  • A string, character vector, or cell array.

  • A pattern object.

  • "A" or 'A' — A variable named A

  • ["A","B"] or {'A','B'} — Two variables named A and B

  • "Var"+digitsPattern(1) — Variables named "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A vector of numbers.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [2 3] — The second and third variables from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects variables of a specified type.

  • vartype("categorical") — All the variables containing categorical values

The table variables you specify can contain numeric, categorical, datetime, or duration values. If xvar and yvar both specify multiple variables, the number of variables must be the same.

Example: plot(tbl,"x",["y1","y2"]) specifies the table variables named y1 and y2 for the y-coordinates.

Example: plot(tbl,"x",2) specifies the second variable for the y-coordinates.

Example: plot(tbl,"x",vartype("numeric")) specifies all numeric variables for the y-coordinates.

ax — Target axes
Axes object | PolarAxes object | GeographicAxes object

Target axes, specified as an Axes object, a PolarAxes object, or a GeographicAxes object. If you do not specify the axes, MATLAB plots into the current axes or it creates an Axes object if one does not exist.

To create a polar plot or geographic plot, specify ax as a PolarAxes or GeographicAxes object. Alternatively, call the polarplot or geoplot function.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: plot([0 1],[2 3],LineWidth=2)

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: plot([0 1],[2 3],"LineWidth",2)

Note:The properties listed here are only a subset. For a complete list, see Line Properties.

Color — Line color
[0 0.4470 0.7410] (default) | RGB triplet | hexadecimal color code | "r" | "g" | "b" | ...

Line color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan""c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

Example: "blue"

Example: [0 0 1]

Example: "#0000FF"

LineStyle — Line style
"-" (default) | "--" | ":" | "-." | "none"

Line style, specified as one of the options listed in this table.

Line StyleDescriptionResulting Line
"-"Solid line

Sample of solid line

"--"Dashed line

Sample of dashed line

":"Dotted line

Sample of dotted line

"-."Dash-dotted line

Sample of dash-dotted line, with alternating dashes and dots

"none"No lineNo line

LineWidth — Line width
0.5 (default) | positive value

Marker — Marker symbol
"none" (default) | "o" | "+" | "*" | "." | ...

Marker symbol, specified as one of the values listed in this table. By default, the object does not display markers. Specifying a marker symbol adds markers at each data point or vertex.

MarkerDescriptionResulting Marker
"o"Circle

Sample of circle marker

"+"Plus sign

Sample of plus sign marker

"*"Asterisk

Sample of asterisk marker

"."Point

Sample of point marker

"x"Cross

Sample of cross marker

"_"Horizontal line

Sample of horizontal line marker

"|"Vertical line

Sample of vertical line marker

"square"Square

Sample of square marker

"diamond"Diamond

Sample of diamond marker

"^"Upward-pointing triangle

Sample of upward-pointing triangle marker

"v"Downward-pointing triangle

Sample of downward-pointing triangle marker

">"Right-pointing triangle

Sample of right-pointing triangle marker

"<"Left-pointing triangle

Sample of left-pointing triangle marker

"pentagram"Pentagram

Sample of pentagram marker

"hexagram"Hexagram

Sample of hexagram marker

"none"No markersNot applicable

MarkerIndices — Indices of data points at which to display markers
1:length(YData) (default) | vector of positive integers | scalar positive integer

Indices of data points at which to display markers, specified as a vector of positive integers. If you do not specify the indices, then MATLAB displays a marker at every data point.

Note:To see the markers, you must also specify a marker symbol.

Example: plot(x,y,"-o","MarkerIndices",[1 5 10]) displays a circle marker at the first, fifth, and tenth data points.

Example: plot(x,y,"-x","MarkerIndices",1:3:length(y)) displays a cross marker every three data points.

Example: plot(x,y,"Marker","square","MarkerIndices",5) displays one square marker at the fifth data point.

MarkerEdgeColor — Marker outline color
"auto" (default) | RGB triplet | hexadecimal color code | "r" | "g" | "b" | ...

Marker outline color, specified as "auto", an RGB triplet, a hexadecimal color code, a color name, or a short name. The default value of "auto" uses the same color as the Color property.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800""#ff8800""#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan""c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

MarkerFaceColor — Marker fill color
"none" (default) | "auto" | RGB triplet | hexadecimal color code | "r" | "g" | "b" | ...

Marker fill color, specified as "auto", an RGB triplet, a hexadecimal color code, a color name, or a short name. The "auto" option uses the same color as the Color property of the parent axes. If you specify "auto" and the axes plot box is invisible, the marker fill color is the color of the figure.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1], for example, [0.4 0.6 0.7].

  • A hexadecimal color code is a string scalar or character vector that starts with a hash symbol (#) followed by three or six hexadecimal digits, which can range from 0 to F. The values are not case sensitive. Therefore, the color codes "#FF8800""#ff8800""#F80", and "#f80" are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
"red""r"[1 0 0]"#FF0000"

Sample of the color red

"green""g"[0 1 0]"#00FF00"

Sample of the color green

"blue""b"[0 0 1]"#0000FF"

Sample of the color blue

"cyan""c"[0 1 1]"#00FFFF"

Sample of the color cyan

"magenta""m"[1 0 1]"#FF00FF"

Sample of the color magenta

"yellow""y"[1 1 0]"#FFFF00"

Sample of the color yellow

"black""k"[0 0 0]"#000000"

Sample of the color black

"white""w"[1 1 1]"#FFFFFF"

Sample of the color white

"none"Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance
[0 0.4470 0.7410]"#0072BD"

Sample of RGB triplet [0 0.4470 0.7410], which appears as dark blue

[0.8500 0.3250 0.0980]"#D95319"

Sample of RGB triplet [0.8500 0.3250 0.0980], which appears as dark orange

[0.9290 0.6940 0.1250]"#EDB120"

Sample of RGB triplet [0.9290 0.6940 0.1250], which appears as dark yellow

[0.4940 0.1840 0.5560]"#7E2F8E"

Sample of RGB triplet [0.4940 0.1840 0.5560], which appears as dark purple

[0.4660 0.6740 0.1880]"#77AC30"

Sample of RGB triplet [0.4660 0.6740 0.1880], which appears as medium green

[0.3010 0.7450 0.9330]"#4DBEEE"

Sample of RGB triplet [0.3010 0.7450 0.9330], which appears as light blue

[0.6350 0.0780 0.1840]"#A2142F"

Sample of RGB triplet [0.6350 0.0780 0.1840], which appears as dark red

MarkerSize — Marker size
6 (default) | positive value

Marker size, specified as a positive value in points, where 1 point = 1/72 of an inch.

DatetimeTickFormat — Format for datetime tick labels
character vector | string

Format for datetime tick labels, specified as the comma-separated pair consisting of "DatetimeTickFormat" and a character vector or string containing a date format. Use the letters A-Z and a-z to construct a custom format. These letters correspond to the Unicode® Locale Data Markup Language (LDML) standard for dates. You can include non-ASCII letter characters such as a hyphen, space, or colon to separate the fields.

If you do not specify a value for "DatetimeTickFormat", then plot automatically optimizes and updates the tick labels based on the axis limits.

Example: "DatetimeTickFormat","eeee, MMMM d, yyyy HH:mm:ss" displays a date and time such as Saturday, April 19, 2014 21:41:06.

The following table shows several common display formats and examples of the formatted output for the date, Saturday, April 19, 2014 at 9:41:06 PM in New York City.

Value of DatetimeTickFormatExample
"yyyy-MM-dd"2014-04-19
"dd/MM/yyyy"19/04/2014
"dd.MM.yyyy"19.04.2014
"yyyy年 MM月 dd日"2014年 04月 19日
"MMMM d, yyyy"April 19, 2014
"eeee, MMMM d, yyyy HH:mm:ss"Saturday, April 19, 2014 21:41:06
"MMMM d, yyyy HH:mm:ss Z"April 19, 2014 21:41:06 -0400

For a complete list of valid letter identifiers, see the Format property for datetime arrays.

DatetimeTickFormat is not a chart line property. You must set the tick format using the name-value pair argument when creating a plot. Alternatively, set the format using the xtickformat and ytickformat functions.

The TickLabelFormat property of the datetime ruler stores the format.

DurationTickFormat — Format for duration tick labels
character vector | string

Format for duration tick labels, specified as the comma-separated pair consisting of "DurationTickFormat" and a character vector or string containing a duration format.

If you do not specify a value for "DurationTickFormat", then plot automatically optimizes and updates the tick labels based on the axis limits.

To display a duration as a single number that includes a fractional part, for example, 1.234 hours, specify one of the values in this table.

Value of DurationTickFormatDescription
"y"Number of exact fixed-length years. A fixed-length year is equal to 365.2425 days.
"d"Number of exact fixed-length days. A fixed-length day is equal to 24 hours.
"h"Number of hours
"m"Number of minutes
"s"Number of seconds

Example: "DurationTickFormat","d" displays duration values in terms of fixed-length days.

To display a duration in the form of a digital timer, specify one of these values.

  • "dd:hh:mm:ss"

  • "hh:mm:ss"

  • "mm:ss"

  • "hh:mm"

In addition, you can display up to nine fractional second digits by appending up to nine S characters.

Example: "DurationTickFormat","hh:mm:ss.SSS" displays the milliseconds of a duration value to three digits.

DurationTickFormat is not a chart line property. You must set the tick format using the name-value pair argument when creating a plot. Alternatively, set the format using the xtickformat and ytickformat functions.

The TickLabelFormat property of the duration ruler stores the format.

其他参考:

MATLAB04:基础绘图-CSDN博客

【matlab进阶学习-7】matlab 图表标注操作_matlab怎么给每条线标注-CSDN博客

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/33751.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

计算机系统基础知识(上)

目录 计算机系统的概述 计算机的硬件 处理器 存储器 总线 接口 外部设备 计算机的软件 操作系统 数据库 文件系统 计算机系统的概述 如图所示计算机系统分为软件和硬件&#xff1a;硬件包括&#xff1a;输入输出设备、存储器&#xff0c;处理器 软件则包括系统软件和…

山东大学-科技文献阅读与翻译(期末复习)(选择题+翻译)

目录 选择题 Chapter1 1.which of the following is not categorized as scientific literature 2.Which of the followings is defined as tertiary(三级文献) literature? 3.Which type of the following international conferences is listed as Number one conference…

如何做好药店布局,实现客流回归?

随着我国医药市场的不断发展&#xff0c;药店数量逐年增多&#xff0c;竞争愈发激烈。在这种背景下&#xff0c;如何做好药店布局&#xff0c;吸引客流回归&#xff0c;成为药店经营者关注的核心问题。 要想实现店铺形象美观大方、有效引导客流动向&#xff0c;增加顾客在店内…

TDengine 推出新连接器,与 Wonderware Historian 无缝连接

在最新发布的TDengine 3.2.3.0 版本中&#xff0c;我们进一步更新了 TDengine 的数据接入功能&#xff0c;推出了一款新的连接器&#xff0c;旨在实现 Wonderware Historian&#xff08;现称为 AVEVA Historian&#xff09;与 TDengine 的集成。这一更新提供了更加便捷和高效的…

设计模式5-策略模式(Strategy)

设计模式5-策略模式 简介目的定义结构策略模式的结构要点 举例说明1. 策略接口2. 具体策略类3. 上下文类4. 客户端代码 策略模式的反例没有使用策略模式的代码 对比分析 简介 策略模式也是属于组件协作模式一种。现代软件专业分工之后的第一个结果是框架语音应用程序的划分。组…

Linux文件IO操作的学习

文件IO&#xff1a; 文件描述符最小是0&#xff0c;非负数 Open的返回值是3&#xff0c;因为0&#xff0c;1&#xff0c;2被占用了。 read&#xff1a; 使用read和write实现cat操作 实现cp复制操作&#xff1a; 生成与原文件大小一致的空洞文件 文件IO和标准IO互相转换可以使用…

OnlyOffice-8.1版本深度测评

2024年6月19日&#xff0c;ONLYOFFICE 发布了最新版本 8.1&#xff0c;带来了超过30项新功能和432个 bug 修复。本文将详细评测该版本的新功能和改进&#xff0c;帮助用户全面了解这一升级带来的实际体验提升。 一、功能全面的 PDF 编辑器 PDF 是日常工作中不可或缺的文件格式…

上海展会闭幕RFID技术助力档案管理

上海国际智慧档案展于近日圆满落幕&#xff0c;各参展企业在展会上展示了最新的档案管理技术和解决方案。其中&#xff0c;铨顺宏以其创新的技术和出色的表现&#xff0c;吸引了众多业内人士和观众的关注。 在此次展会上&#xff0c;铨顺宏展示了其全新的RFID智能档案管理。能够…

哈啰集团全面接入通义灵码,AI 生成代码占比 20%,研发提效 12%

6 月 21 日&#xff0c;在阿里云 AI 智领者峰会上海站&#xff0c;哈啰集团算法总监贾立宣布&#xff0c; 哈啰集团已全面接入阿里云通义灵码专属版&#xff0c; 不仅提升了内部研发效率&#xff0c;实现 AI 代码采用率超过 20%&#xff0c;还将灵码接入了哈啰自研 Copilot “海…

【CPP】插入排序:直接插入排序、希尔排序

目录 1.插入排序1.1直接插入排序简介代码分析 1.2直接插入对比冒泡排序简介代码对比分析(直接插入排序与冒泡的复杂度效率区别) 1.3希尔排序简介代码分析 1.插入排序 基本思想&#xff1a;把一个待排数字按照关键码值插入到一个有序序列中&#xff0c;得到一个新的有序序列。 …

“Cannot resolve ch.qos.logback:logback-classic:1.2.3”问题解决办法

当我们添加依赖配置时&#xff0c;通常会遇见如下错误&#xff1a; 这个问题是由于项目中使用了 logback-classic 版本1.2.3&#xff0c;但是无法从当前所配置的仓库中解析到这个特定的版本。可以尝试检查依赖配置&#xff0c;确保指定的仓库中包含了 logback-classic 版本1.2.…

MCU的最佳存储方案CS创世 SD NAND

大家都知道MCU是一种"麻雀"虽小&#xff0c;却"五脏俱全"的主控。它的应用领域非常广泛&#xff0c;小到手机手表&#xff0c;大到航空航天的设备上都会用到MCU.市面上目前几个主流厂商有意法半导体&#xff08;其中最经典的一款就是STM32系列&#xff09;…

【思科】IPv6 过渡技术 - IPv6 in IPv4隧道

【思科】IPv6 过渡技术 - IPv6 in IPv4隧道 实验要求实现思路IPv6 in IPv4 与 GRE 不同点注意点配置R1基础配置OSPFv3 局域网可达 R2基础配置局域网环境(OSPFv3)&#xff1a;IPv6 网络IPv6 in IPv4隧道 R3R4基础配置局域网环境(OSPFv3)&#xff1a;IPv6 网络IPv6 in IPv4隧道 R…

【机器学习】——【线性回归模型】——详细【学习路线】

目录 1. 引言 2. 线性回归理论基础 2.1 线性模型概述 2.2 最小二乘法 3. 数学基础 3.1 矩阵运算 3.2 微积分 3.3 统计学 4. 实现与应用 4.1 使用Scikit-learn实现线性回归 4.2 模型评估 5. 深入理解 5.1 多元线性回归 5.2 特征选择 5.3 理解模型内部 6. 实战与项…

算法学习DAY01

目录 一、算法优劣的核心指标 二、常数时间操作 1、常见的常数时间的操作 2、位运算 &#xff08;1&#xff09;&#xff08;<<&#xff09;左移运算符 &#xff08;2&#xff09;&#xff08;>>&#xff09;右移运算符 &#xff08;3&#xff09;&#xff0…

第27课 原理图的简介

什么是原理图&#xff1f; 原理图就是由元器件连接而成的电路图&#xff0c;它表征了你所设计电路的基本原理。 原理图上的所有元器件&#xff0c;都要从你所画好的元器件符号库中调用。元器件的信息会显示在原理图上&#xff0c;如型号、位号、特性值等。 按照我们的设计&am…

WPF/C#:数据绑定到方法

在WPF Samples中有一个关于数据绑定到方法的Demo&#xff0c;该Demo结构如下&#xff1a; 运行效果如下所示&#xff1a; 来看看是如何实现的。 先来看下MainWindow.xaml中的内容&#xff1a; <Window.Resources><ObjectDataProvider ObjectType"{x:Type local…

【2024.6.25】今日 IT之家精选新闻

人不走空 &#x1f308;个人主页&#xff1a;人不走空 &#x1f496;系列专栏&#xff1a;算法专题 ⏰诗词歌赋&#xff1a;斯是陋室&#xff0c;惟吾德馨 目录 &#x1f308;个人主页&#xff1a;人不走空 &#x1f496;系列专栏&#xff1a;算法专题 ⏰诗词歌…

电源集成:智能真无线耳机设计中的通信接口

真无线耳机&#xff08;TWS 耳机&#xff09;由于电池寿命更长、功能更强大、设计更吸引人以及价格更优惠&#xff0c;因此继续变得更具吸引力。随着耳机制造商专注于小型化和设计改进&#xff0c;并迅速采用功能来增强用户体验&#xff0c;他们能够在强大且竞争激烈的市场中吸…

提示缺少Microsoft Visual C++ 2019 Redistributable Package (x64)(下载)

下载地址&#xff1a;这个是官网下载地址&#xff1a;Microsoft Visual C 2019 Redistributable Package (x64) 步骤&#xff1a; 第一步&#xff1a;点开链接&#xff0c;找到下图所示的东西 第二步&#xff1a;点击保存下载 第三步&#xff1a;双击运行安装 第四步&#xf…