xscale

Gets or sets the scale of the x-axis, linear or logarithmic.

Category: Graphics > Formatting and Annotation

Syntax

xscale(option)

Sets the scale to 'linear' or 'log'.

sc = xscale

Returns the current scale as text.

xscale(ax, ___)

Acts on the axes ax.

Description

A logarithmic axis shows equal ratios as equal distances, which suits data that spans several orders of magnitude. Only positive values can be drawn on it; zero and negative values are omitted.

The setting is stored in the axes property XScale. semilogx and loglog draw a plot and set the scale in a single call.

Input arguments

option
'linear' (default) or 'log'.

Output arguments

sc
Current scale, 'linear' or 'log'.

Example

Logarithmic x-axis

x = logspace(0, 3, 50);
plot(x, sqrt(x))
xscale('log')
xscale
Output
ans = 'log'

See also

yscale semilogx loglog xlim xticks