semilogx

Plots a line with a base-10 logarithmic x-axis and a linear y-axis.

Category: Graphics > 2-D and 3-D Plots

Syntax

semilogx(X, Y)

Plots Y against X with the x-axis on a log scale.

semilogx(X, Y, LineSpec)

Sets color, marker and line style with a short string.

h = semilogx(___)

Also returns the line handles.

Description

It takes the same arguments as plot, but spaces the x tick marks by powers of ten. A power law in x, or a response that spans several decades of frequency, becomes easy to read on this axis.

Values of X that are zero or negative cannot be placed on a logarithmic axis and are not drawn.

Input arguments

X, Y
Vectors or matrices of coordinates. X must be positive to appear on a log axis.

Output arguments

h
Handles of the plotted lines.

Example

Logarithm against a log axis

x = logspace(0, 3, 50);
semilogx(x, log10(x))
grid on
xlabel('x'), ylabel('log10(x)')

In the app, the figure is drawn below the code.

See also

semilogy loglog plot logspace