RunMat
GitHub

loglog — Plot data on logarithmic x and y axes for power laws, scaling analysis, and MATLAB loglog comparisons.

loglog builds line objects through the shared RunMat line-plot path and then marks both axes as logarithmic. It is useful for power-law relationships, spectrum-style plots, and any comparison where both dimensions span multiple decades in the MATLAB loglog style.

How loglog works in RunMat

  • 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'

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

These functions work well alongside loglog. Each page has runnable examples you can try in the browser.

plot, semilogx, semilogy, axis

More plotting resources

Open-source implementation

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

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.

  • Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
  • Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
  • A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.

Getting started · Benchmarks · Pricing

Try RunMat for free

Open the sandbox and start running MATLAB code in seconds. No account required.