loglog
Log-log scale plot
Syntax
Description
Vector and Matrix Data
loglog(
plots
x- and y-coordinates using a base-10 logarithmic
scale on the x-axis and the y-axis.X
,Y
)
To plot a set of coordinates connected by line segments, specify
X
andY
as vectors of the same length.To plot multiple sets of coordinates on the same set of axes, specify at least one of
X
orY
as a matrix.
loglog(
plots Y
)Y
against
an implicit set of x-coordinates.
If
Y
is a vector, the x-coordinates range from 1 tolength(Y)
.If
Y
is a matrix, the plot contains one line for each column inY
. The x-coordinates range from 1 to the number of rows inY
.
If Y
contains complex numbers,
loglog
plots the imaginary part of Y
versus the
real part of Y
. However, if you specify both X
and
Y
, MATLAB® ignores the imaginary part.
Table Data
loglog(
plots the variables tbl
,xvar
,yvar
)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)
Additional Options
loglog(
displays the plot
in the target axes. Specify the axes as the first argument in any of the previous
syntaxes.ax
,___)
loglog(___,
specifies
Name,Value
)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.
p = loglog(___)
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.
Examples
Input Arguments
Name-Value Arguments
Tips
Use
NaN
orInf
to create breaks in the lines. For example, this code plots a line with a break betweeny=2
andy=4
.loglog([1 2 3 4 5],[1 2 NaN 4 5])
The
loglog
function uses colors and line styles based on theColorOrder
andLineStyleOrder
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.You can change the colors and the line styles after plotting by setting the
ColorOrder
orLineStyleOrder
properties on the axes. You can also call thecolororder
function to change the color order for all the axes in the figure.
Algorithms
The loglog
function plots coordinates on a log scale by setting the
XScale
and YScale
properties of the axes to
'log'
. However, if the axes hold
state is 'on'
before you call
loglog
, those properties do not change, and the plot might display on a
linear or semilog scale.