RunMat
GitHub

loglog — Plot data on logarithmic x and y axes in MATLAB and RunMat.

loglog(x, y, ...) creates line plots and sets both axes to logarithmic scale. Argument handling, returned handles, and axis-scaling behavior follow MATLAB semantics.

Syntax

h = loglog(Y)
h = loglog(X, Y)
h = loglog(args...)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYesY data vector/matrix.
XNumericArrayYesX data vector/matrix.
argsAnyVariadicPlot-style inputs: optional axes handle, style tokens, and Name/Value pairs.

Returns

NameTypeDescription
hNumericScalarLine handle.

Errors

IdentifierWhenMessage
RunMat:loglog:PlotFailedUnderlying plot rendering/parsing fails while building the log-log plot.loglog: plot operation failed
RunMat:loglog:LogAxisFailedApplying logarithmic axis modes fails.loglog: failed to apply logarithmic axis mode

How loglog works

  • The returned value is a numeric line handle.
  • Both x and y axes are switched to log scale on the active axes.
  • Axes scale state remains subplot-local.
  • Logarithmic axes are meaningful for positive-domain data on both x and y.

Examples

Plot a power-law curve on logarithmic axes

x = logspace(0, 3, 200);
loglog(x, x.^(-1.5));

Compare multiple scaling laws

x = logspace(0, 3, 200);
h1 = loglog(x, x.^(-1));
set(h1, 'DisplayName', 'x^{-1}');
hold on;
h2 = loglog(x, x.^(-2));
set(h2, 'DisplayName', 'x^{-2}');
legend;

Inspect both axes after plotting

x = logspace(0, 2, 50);
loglog(x, x.^2);
ax = gca;
xscale = get(ax, 'XScale');
yscale = get(ax, 'YScale');

Expected output:

% Both axes report 'log'

Using loglog with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how loglog changes the result.

Run a small loglog example, explain the result, then change one input and compare the output.

FAQ

Why do power-law relationships appear as straight lines on a log-log plot?

Taking the log of both sides of y = a * x^b gives log(y) = log(a) + b * log(x), which is linear in log-space. The slope of the line equals the exponent b, and the y-intercept gives log(a). That's why log-log is the standard way to identify and compare power laws.

How is loglog different from semilogx or semilogy?

semilogx only logs the x-axis (linear y), semilogy only logs the y-axis (linear x), and loglog logs both. Use loglog when both dimensions span orders of magnitude — spectrum plots, scaling benchmarks, fractal dimension analysis.

Can I mix loglog with other scale modes in a subplot layout?

Yes. Axes scale state is subplot-local, so loglog in one panel doesn't affect neighbors.

subplot(1, 2, 1);
loglog(x, x.^(-2));
subplot(1, 2, 2);
plot(x, x.^(-2)); % linear axes here

2D Charts

area · bar · errorbar · heatmap · hist · histogram · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surf · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

cla · clf · figure · fill3 · hold · patch · polarplot · print · suptitle · xline · yline

More plotting resources

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how loglog is executed, line by line, in Rust.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.