Loglog
Log-log scale plot
Syntax
描述
向量和Matrix Data
Loglog(
情节Y
)Y
违反一套隐性x- 坐标。
如果
Y
is a vector, thex-coordinates range from 1 to冗长)
。如果
Y
是一个矩阵,该图在每列中包含一行Y
。这x-coordinates range from 1 to the number of rows inY
。
如果Y
contains complex numbers,Loglog
情节the imaginary part ofY
versus the real part ofY
。However, if you specify bothX
和Y
, MATLAB®ignores the imaginary part.
表数据
Additional Options
Loglog(___,
指定名称,价值
)Line
使用一个或多个名称值参数的属性。这些属性适用于所有绘制线。在任何先前的语法中的所有参数之后,指定名称值参数。有关属性列表,请参见Line Properties。
p = loglog(___)
返回一个Line
object or an array ofLine
objects. Usep
to modify properties of the plot after creating it. For a list of properties, seeLine Properties。
例子
绘制一行
Definex
作为50个对数间隔数的向量在间隔上[
]. Definey
as
。然后绘制x
和y
, 和call the网格
function to show the grid lines.
x = logspace(-1,2);y =2。^x;loglog(x,y)网格上
Plot Multiple Lines
Create a vector ofx- 坐标和两个向量y- 坐标。通过通过逗号分隔来绘制两行x-ypairs toLoglog
。
x = logspace(-1,2);y1 = 10.^x;y2 = 1./10.^;Loglog(x,y1,x,y2) grid上
Alternatively, you can create the same plot with onex-y通过指定配对y作为矩阵:loglog(x,[y1; y2])
。
指定轴标签和刻度值
Create a set ofx- 和y- 协调并在日志图中显示它们。
x = logspace(-1,2,10000);y = 5 + 3*sin(x);loglog(x,y)
Call theyticks
功能定位y- 轴刻度值以整个数字增量沿y-轴。这n createx- 和y-axis labels by calling theXLABEL
和ylabel
功能。
Yticks([3 4 5 6 7])Xlabel('X')ylabel('5 + 3 sin(x)')
绘图点作为没有线条的标记
Create a set ofx- 和y- 协调并在日志图中显示它们。Specify the line style as's'
to display square markers without connecting lines. Specify the marker fill color as the RGB triplet[0 0.447 0.741]
,对应于蓝色的深色阴影。
x = logspace(-1,2,20); y = 10.^x; loglog(x,y,'s','MarkerFaceColor',[0 0.447 0.741])网格上
Add a Legend
Create two sets ofx- 和y- 协调并在日志图中显示它们。通过调用传奇
function and specifying the location as'西北'
。
x = logspace(-1,2,10000);y1 = 5 + 3*sin(x/4);y2 = 5-3*sin(x/4);loglog(x,y1,x,y2,' - ') legend('Signal 1','Signal 2','地点','西北')
Specifyy- 仅坐标
当您仅指定一个坐标向量时,Loglog
情节those coordinates against the values1:length(y)
。例如,定义y
作为6个值的向量0.001
和100
。Create a log-log plot of y.
y = [0.001 0.01 0.1 1 10 100]; loglog(y) grid上
如果指定y
as a matrix, the columns of y are plotted against the values1:size(y,1)
。例如,定义y
as a 5-by-3 matrix and pass it to theLoglog
功能。结果图包含3行,每行都有x-coordinates that range from1
to5
。
y = [0.0010 0.0100 0.1000 0.0100 0.1000 1.0000 0.1000 1.0000 10.0000 1.0000 10.5000 100.0000 10.0000 100.0000 1000.0000]; loglog(y) grid上
绘图坐标从表
Since R2022a
A convenient way to plot data from a table is to pass the table to theLoglog
function and specify the variables to plot.
Create a table containing two variables. Then display the first three rows of the table.
输入= logspace(-1,2)';输出=10。^输入;tbl =表(输入,输出);头(TBL,3)
ans =3×2桌输入输出_______ ______ 0.1 1.2589 0.11514 1.3036 0.13257 1.357
绘制输入
变量x- 轴和Output
变量y-轴。返回Line
对象为p
并打开轴网格。请注意,轴标签匹配变量名。
p = loglog(tbl,“输入”,“输出”); grid上
要修改行的各个方面,请设置LineStyle
,Color
, 和Marker
properties on theLine
目的。例如,将行更改为带有点标记的红色虚线。
p.linestyle =":";p.olor ="red";p.marker =“。”;
在一个轴上绘制多个表变量
Since R2022a
创建一个包含三个变量的表。然后在表中显示前三行。
输入= logspace(-1,2)';Output1 = 10.^Input; Output2 = 1./10.^Input; tbl = table(Input,Output1,Output2); head(tbl,3)
ans =3×3 table输入输出1输出2 _______ _______ _______ 0.1 1.2589 0.79433 0.11514 1.3036 0.76711 0.13257 1.357 0.73693
绘制输入
变量x- 轴和Output1
和Output2
变量y-轴。Add a legend. Notice that the legend labels match the variable names.
loglog(tbl,“输入”,[["Output1""Output2"]) grid上传奇
Specify Target Axes
创建一个平铺图的布局'flow'
瓷砖布置,使轴填充布局中的可用空间。接下来,致电nexttile
功能创建轴对象并将其返回为ax1
。这n display a log-log plot by passingax1
到Loglog
功能。
Tiledlayout('flow') ax1 = nexttile; x = logspace(-1,2); y1 = 10.^x; loglog(ax1,x,y1)
Repeat the process to create a second axes object and a second log-log plot.
ax2 = nexttile;y2 = 1./10.^;LOGLOG(AX2,X,Y2)
绘制后更改线特征
创建一个包含两条线的日志图图,然后返回变量中的行对象LG
。
x = logspace(-1,2);y1 = 10.^x;y2 = 1./10.^;lg = loglog(x,y1,x,y2);
将第一行的宽度更改为2
, 和change the color of the second line to purple.
LG(1).LineWidth = 2; lg(2).Color = [0.4 0 1];
输入Arguments
X
—x-coordinates
scalar|vector|matrix
x- 坐标,指定为标量,向量或矩阵。大小和形状X
depends on the shape of your data and the type of plot you want to create. This table describes the most common situations.
图的类型 | 如何指定坐标 |
---|---|
单点 | Specify Loglog(1,2,'o')
|
一组点 | Specify Loglog([1 2 3],[4; 5; 6]) |
Multiple sets of points (使用向量) |
Specify consecutive pairs of Loglog([1 2 3],[4 5 6],[1 2 3],[7 8 9]) |
Multiple sets of points (using matrices) |
如果all the sets share the samex- ory-coordinates, specify the shared coordinates as a vector and the other coordinates as a matrix. The length of the vector must match one of the dimensions of the matrix. For example: Loglog([1 2 3],[4 5 6; 7 8 9]) Loglog 情节上e line for each column in the matrix.Alternatively, specify loglog([1 2 3; 4 5 6],[7 8 9; 10 11 12]) |
Loglog
might exclude coordinates in some cases:
如果the coordinates include positive and negative values, only the positive values are displayed.
如果坐标全部为负,则所有值均以适当的符号显示在日志刻度上。
Zero values are not displayed.
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|uint8
|UINT16
|uint32
|uint64
Y
—y-coordinates
scalar|vector|matrix
y- 坐标,指定为标量,向量或矩阵。大小和形状Y
depends on the shape of your data and the type of plot you want to create. This table describes the most common situations.
图的类型 | 如何指定坐标 |
---|---|
单点 | Specify Loglog(1,2,'o')
|
一组点 | Specify Loglog([1 2 3],[4; 5; 6]) |
Multiple sets of points (使用向量) |
Specify consecutive pairs of Loglog([1 2 3],[4 5 6],[1 2 3],[7 8 9]) |
Multiple sets of points (using matrices) |
如果all the sets share the samex- ory-coordinates, specify the shared coordinates as a vector and the other coordinates as a matrix. The length of the vector must match one of the dimensions of the matrix. For example: Loglog([1 2 3],[4 5 6; 7 8 9]) Loglog 情节上e line for each column in the matrix.Alternatively, specify loglog([1 2 3; 4 5 6],[7 8 9; 10 11 12]) |
Loglog
might exclude coordinates in some cases:
如果the coordinates include positive and negative values, only the positive values are displayed.
如果坐标全部为负,则所有值均以适当的符号显示在日志刻度上。
Zero values are not displayed.
数据类型:single
|双倍的
|int8
|INT16
|INT32
|INT64
|uint8
|UINT16
|uint32
|uint64
LinesPec
—Line style, marker, and color
角色向量|string
Line style, marker, and color, specified as a character vector or string 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.
例子:'--or'
是带有圆形标记的红色虚线
Line Style | 描述 | Resulting Line |
---|---|---|
“- - -” |
Solid line |
|
' - ' |
Dashed line |
|
':' |
虚线 |
|
'-.' |
Dash-dotted line |
|
Marker | 描述 | Resulting Marker |
---|---|---|
'o' |
Circle |
|
'+' |
加号 |
|
'*' |
Asterisk |
|
'.' |
观点 |
|
'X' |
叉 |
|
'_' |
Horizontal line |
|
'|' |
Vertical line |
|
's' |
正方形 |
|
'd' |
Diamond |
|
'^' |
向上的三角形 |
|
'v' |
Downward-pointing triangle |
|
'>' |
Right-pointing triangle |
|
'<' |
Left-pointing triangle |
|
'p' |
Pentagram |
|
'H' |
Hexagram |
|
颜色名称 | 简称 | RGB Triplet | 外貌 |
---|---|---|---|
“红色” |
'r' |
[1 0 0] |
|
'绿色' |
'G' |
[0 1 0] |
|
'蓝色的' |
'b' |
[0 0 1] |
|
'青色' |
'c' |
[0 1 1] |
|
'品红' |
'M' |
[1 0 1] |
|
'yellow' |
'y' |
[1 1 0] |
|
'black' |
'K' |
[0 0 0] |
|
'white' |
'w' |
[1 1 1] |
|
TBL
—Source table
桌子|timetable
源表包含要绘制的数据,指定为表或时间表。
xvar
—包含表变量x-coordinates
角色向量|字符串数组|单元阵列|图案|numeric scalar or vector|logical vector|vartype()
表变量包含x-coordinates, specified using one of the indexing schemes from the table.
Indexing Scheme | 例子 |
---|---|
可变名称:
|
|
可变索引:
|
|
变量类型:
|
|
这桌子variables you specify can contain any numeric values. However,Loglog
可能以与指定时相同的方式从图中排除负值和零值X
和Y
作为包含负值或零值的向量。
如果xvar
和yvar
两者都指定多个变量,变量的数量必须相同。
例子:loglog(tbl,[“ x1”,“ x2”],“ y”)
指定the table variables namedx1
和x2
for thex- 坐标。
例子:loglog(tbl,2,"y")
指定第二个变量x- 坐标。
例子:loglog(tbl,vartype("numeric"),"y")
指定所有数字变量x- 坐标。
yvar
—包含表变量y-coordinates
角色向量|字符串数组|单元阵列|图案|numeric scalar or vector|logical vector|vartype()
表变量包含y-coordinates, specified using one of the indexing schemes from the table.
Indexing Scheme | 例子 |
---|---|
可变名称:
|
|
可变索引:
|
|
变量类型:
|
|
这桌子variables you specify can contain any numeric values. However,Loglog
可能以与指定时相同的方式从图中排除负值和零值X
和Y
作为包含负值或零值的向量。
如果xvar
和yvar
两者都指定多个变量,变量的数量必须相同。
例子:loglog(tbl,"x",["y1","y2"])
指定the table variables namedy1
和y2
for they- 坐标。
例子:loglog(tbl,“ x”,2)
指定第二个变量y- 坐标。
例子:loglog(tbl,“ x”,vartype(“ numeric”))
指定所有数字变量y- 坐标。
ax
—目标轴
轴
object
目标轴, specified as an轴
目的。如果you do not specify the axes and if the current axes is Cartesian, thenLoglog
uses the current axes.
Name-Value Arguments
将可选的参数对Name1=Value1,...,NameN=ValueN
, 在哪里Name
is the argument name and价值
是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。
Before R2021a, use commas to separate each name and value, and encloseName
in quotes.
例子:Loglog([1 2],[3 4],'Color','red')
指定图块的红线。
Note
这properties listed here are only a subset. For a complete list, seeLine Properties。
Color
—Color
[0 0.4470 0.7410]
(default) |RGB三胞胎|十六进制的颜色代码|'r'
|'G'
|'b'
| ...
Color, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. The color you specify sets the line color. It also sets the marker edge color when theMarkeredGecolor
属性设置为'auto'
。
对于自定义颜色,请指定RGB三重态或十六进制颜色代码。
RGB三重态是一个三元素行矢量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内
[0,1]
;例如,[0.4 0.6 0.7]
。十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(
#
),然后是三个或六个十六进制的数字,范围从0
toF
。这些值不敏感。因此,颜色代码'#ff8800'
,'#ff8800'
,'#f80'
, 和'#f80'
are equivalent.
另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。
颜色名称 | 简称 | RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|---|---|
“红色” |
'r' |
[1 0 0] |
'#FF0000' |
|
'绿色' |
'G' |
[0 1 0] |
'#00FF00' |
|
'蓝色的' |
'b' |
[0 0 1] |
'#0000FF' |
|
'青色' |
'c' |
[0 1 1] |
'#00ffff' |
|
'品红' |
'M' |
[1 0 1] |
'#ff00ff' |
|
'yellow' |
'y' |
[1 1 0] |
'#FFFF00' |
|
'black' |
'K' |
[0 0 0] |
'#000000' |
|
'white' |
'w' |
[1 1 1] |
'#ffffff' |
|
'none' |
Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|
[0 0.4470 0.7410] |
'#0072BD' |
|
[0.8500 0.3250 0.0980] |
'#D95319' |
|
[0.9290 0.6940 0.1250] |
'#EDB120' |
|
[0.4940 0.1840 0.5560] |
'#7E2F8E' |
|
[0.4660 0.6740 0.1880] |
'#77AC30' |
|
[0.3010 0.7450 0.9330] |
'#4dbeee' |
|
[0.6350 0.0780 0.1840] |
'#a2142f' |
|
行宽
—Line width
0.5
(default) |正值
线宽,指定为点的正值,其中1分= 1/72英寸。如果线具有标记,则行宽也会影响标记边缘。
这line width cannot be thinner than the width of a pixel. If you set the line width to a value that is less than the width of a pixel on your system, the line displays as one pixel wide.
MarkerSize
—标记大小
6
(default) |正值
标记大小, specified as a positive value in points, where 1 point = 1/72 of an inch.
MarkeredGecolor
—标记大纲颜色
'auto'
(default) |RGB三胞胎|十六进制的颜色代码|'r'
|'G'
|'b'
| ...
标记大纲颜色,指定为'auto'
,一个RGB三重态,十六进制的颜色代码,颜色名称或短名称。这default value of'auto'
uses the same color as theColor
property.
对于自定义颜色,请指定RGB三重态或十六进制颜色代码。
RGB三重态是一个三元素行矢量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内
[0,1]
;例如,[0.4 0.6 0.7]
。十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(
#
),然后是三个或六个十六进制的数字,范围从0
toF
。这些值不敏感。因此,颜色代码'#ff8800'
,'#ff8800'
,'#f80'
, 和'#f80'
are equivalent.
另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。
颜色名称 | 简称 | RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|---|---|
“红色” |
'r' |
[1 0 0] |
'#FF0000' |
|
'绿色' |
'G' |
[0 1 0] |
'#00FF00' |
|
'蓝色的' |
'b' |
[0 0 1] |
'#0000FF' |
|
'青色' |
'c' |
[0 1 1] |
'#00ffff' |
|
'品红' |
'M' |
[1 0 1] |
'#ff00ff' |
|
'yellow' |
'y' |
[1 1 0] |
'#FFFF00' |
|
'black' |
'K' |
[0 0 0] |
'#000000' |
|
'white' |
'w' |
[1 1 1] |
'#ffffff' |
|
'none' |
Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|
[0 0.4470 0.7410] |
'#0072BD' |
|
[0.8500 0.3250 0.0980] |
'#D95319' |
|
[0.9290 0.6940 0.1250] |
'#EDB120' |
|
[0.4940 0.1840 0.5560] |
'#7E2F8E' |
|
[0.4660 0.6740 0.1880] |
'#77AC30' |
|
[0.3010 0.7450 0.9330] |
'#4dbeee' |
|
[0.6350 0.0780 0.1840] |
'#a2142f' |
|
MarkerfaceColor
—标记填充颜色
'none'
(default) |'auto'
|RGB三胞胎|十六进制的颜色代码|'r'
|'G'
|'b'
| ...
标记填充颜色,指定为'auto'
,一个RGB三重态,十六进制的颜色代码,颜色名称或短名称。这'auto'
option uses the same color as theColor
父轴的属性。如果指定'auto'
轴图框是看不见的,标记填充颜色是图的颜色。
对于自定义颜色,请指定RGB三重态或十六进制颜色代码。
RGB三重态是一个三元素行矢量,其元素指定了颜色的红色,绿色和蓝色组件的强度。强度必须在范围内
[0,1]
;例如,[0.4 0.6 0.7]
。十六进制的颜色代码是字符向量或字符串标量,以哈希符号开头(
#
),然后是三个或六个十六进制的数字,范围从0
toF
。这些值不敏感。因此,颜色代码'#ff8800'
,'#ff8800'
,'#f80'
, 和'#f80'
are equivalent.
另外,您可以按名称指定一些常见的颜色。该表列出了命名的颜色选项,等效的RGB三重态和十六进制颜色代码。
颜色名称 | 简称 | RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|---|---|
“红色” |
'r' |
[1 0 0] |
'#FF0000' |
|
'绿色' |
'G' |
[0 1 0] |
'#00FF00' |
|
'蓝色的' |
'b' |
[0 0 1] |
'#0000FF' |
|
'青色' |
'c' |
[0 1 1] |
'#00ffff' |
|
'品红' |
'M' |
[1 0 1] |
'#ff00ff' |
|
'yellow' |
'y' |
[1 1 0] |
'#FFFF00' |
|
'black' |
'K' |
[0 0 0] |
'#000000' |
|
'white' |
'w' |
[1 1 1] |
'#ffffff' |
|
'none' |
Not applicable | Not applicable | Not applicable | No color |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | 外貌 |
---|---|---|
[0 0.4470 0.7410] |
'#0072BD' |
|
[0.8500 0.3250 0.0980] |
'#D95319' |
|
[0.9290 0.6940 0.1250] |
'#EDB120' |
|
[0.4940 0.1840 0.5560] |
'#7E2F8E' |
|
[0.4660 0.6740 0.1880] |
'#77AC30' |
|
[0.3010 0.7450 0.9330] |
'#4dbeee' |
|
[0.6350 0.0780 0.1840] |
'#a2142f' |
|
提示
利用
NaN
或者inf
to create breaks in the lines. For example, this code plots a line with a break betweeny = 2
和y = 4
。Loglog([1 2 3 4 5],[1 2 NaN 4 5])
这
Loglog
function uses colors and line styles based on the色点
和Linestyleorder
properties of the axes.Loglog
cycles through the colors with the first line style. Then, it cycles through the colors again with each additional line style.您可以通过设置绘制绘图后更改颜色和线样式
色点
或者Linestyleorder
properties on the axes. You can also call thecolororder
function to change the color order for all the axes in the figure.
算法
这Loglog
功能图通过设置日志刻度坐标XScale
和YScale
properties of the axes to'log'
。但是,如果轴hold
状态是'on'
在打电话之前Loglog
,这些属性不会改变,图可能以线性或半尺度显示。
Extended Capabilities
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
用法注释和限制:
This function accepts GPU arrays, but does not run on a GPU.
有关更多信息,请参阅Run MATLAB Functions on a GPU(Parallel Computing Toolbox)。
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
Version History
在R2006a之前引入R2022a: Pass tables directly toLoglog
Create plots by passing a table to theLoglog
函数随后是要绘制的变量。当您将数据指定为表格时,使用表变量名称自动标记轴标签和传说(如果存在)。
See Also
Functions
Properties
Topics
matlab命令
You clicked a link that corresponds to this MATLAB command:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:。
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- América Latina(Español)
- 加拿大(英语)
- 美国(英语)