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
Y- Type
NumericArray- Required
- Yes
- Description
- Y data vector/matrix.
X- Type
NumericArray- Required
- Yes
- Description
- X data vector/matrix.
args- Type
Any- Required
- Variadic
- Description
- Plot-style inputs: optional axes handle, style tokens, and Name/Value pairs.
Returns
h- Type
NumericScalar- Description
- Line handle.
Errors
RunMat:loglog:PlotFailed- When
- Underlying plot rendering/parsing fails while building the log-log plot.
- Message
loglog: plot operation failed
RunMat:loglog:LogAxisFailed- When
- Applying logarithmic axis modes fails.
- Message
loglog: failed to apply logarithmic axis mode
RunMat:plotting:TooManyOutputs- When
- More than one output is requested from a coordinate chart constructor.
- Message
plotting: too many output arguments
Behavior
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.
Runtime contract and boundaries
The result is a host graphics handle, not a numeric coordinate array. Coordinate parsing, native source storage, series expansion, style validation and graphics state use the existing plotting owners. Numeric handle aliases are resolved at Runtime, so static inference does not guess that a scalar coordinate denotes axes. The line, bar, barh and area constructors may return a row of handles; the other identities return the first created handle. More than one language output is rejected before chart work.
Single and double source data use their native storage where the chart has typed source properties; all eight integer classes use the declared identity-specific coordinate/control rules. Rendering is an explicit floating geometry boundary. In particular errorbar, bar, barh and area convert client graphics data to floating geometry; this does not certify exact integer-valued rendered pixels. Complex, logical, sparse, empty and matrix admission is decided by each existing numerical/shape parser, not by this shared ingress. Unsupported representations raise the existing parser diagnostic rather than being assumed fully MATLAB compatible.
Direct GPU rendering is conditional on the actual owning provider, live physical input leases, floating class/storage, supported shape/style, compatible shared device exports and native plotting feature availability. A pre-effect unavailable direct route may take the existing client path; a failed or partially completed export/reduction/emission is terminal and never permission to replay on the host. Source-property reads and figure persistence can perform later explicit readback. There is no elementwise/reduction fusion, distributed execution or portable numeric provider kernel for these graphics sinks.
User-interface capability and host-callback effects describe graphics creation/presentation, not numeric purity. Portable Runtime linking and an ordinary execution stack allow Native and Wasm ingress; actual presentation requires the installed graphics host. Retained chart data, style metadata, renderer buffers and serialization are separate lifetimes. Current chart scratch/state has no complete finite allocation owner: Managed policy is rejected before argument extraction, gather or chart mutation through the existing HostAllocationReceipt authority. Ordinary Unbounded resident and host routes remain available. Issuer/policy/cancellation are fenced before publication and errors carry Never replay. This refusal, unbounded host loops, provider/renderer-private allocations, full property parity and measured performance remain open obligations; Incomplete/Partial is not a completion certificate.
Supported representations and remaining forms
Coordinates use real single/double Tensor storage or native integer storage. Scalar logical coordinates pass through the existing NumericInput double conversion; logical arrays, complex arrays, sparse arrays, categorical and datetime coordinate objects do not have a NumericInput representation and are not implemented by this chart owner.
Y-only calls, explicit X/Y pairs, repeated series, optional leading axes, LineSpec and shared line name/value controls delegate to the canonical plot owner with the actual RuntimeContext. Implicit indices are one-based doubles. Scalar numeric Y is normalized by NumericInput; empty Y produces matching empty coordinates. Host matrix expansion preserves native single/double/integer class and exact selected values, with no whole-matrix materialization per selected row or column. Log scaling changes display coordinates, not the source properties. Nonpositive values break logarithmic rendered segments rather than changing stored coordinates.
The owning call explicitly sets both axes logarithmic on its selected subplot axes after plotting succeeds. Each neighboring subplot retains its own scale state.
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'Rendered loglog example
problem_size = logspace(1, 6, 300);
measured = 0.018*problem_size.^1.42 .* (1 + 0.035*sin(log(problem_size)));
reference = 0.018*problem_size.^1.42;
h1 = loglog(problem_size, measured);
set(h1, 'LineWidth', 2, 'DisplayName', 'Measured');
hold on;
h2 = loglog(problem_size, reference, '--');
set(h2, 'LineWidth', 1.5, 'DisplayName', 'n^{1.42} reference');
hold off;
title('Scaling Law Comparison');
xlabel('Problem size');
ylabel('Work units');
legend();
grid on;
Compare this result with other chart types in the plot examples.
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 hereRelated Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
More plotting resources
Source you can read
Every RunMat function's source is public. Read exactly how loglog is executed, line by line, in Rust.
- View the source for loglog in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.