semilogy — Plot data with a logarithmic y-axis using MATLAB-compatible semilogy call patterns.
semilogy creates line plots like plot and configures the active axes to logarithmic scaling on Y. It follows MATLAB-compatible argument forms, axes targeting, and handle behavior.
Syntax
h = semilogy(Y)
h = semilogy(X, Y)
h = semilogy(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:semilogy:PlotFailed- When
- Underlying plot rendering/parsing fails while building the semilog plot.
- Message
semilogy: plot operation failed
RunMat:semilogy:LogAxisFailed- When
- Applying logarithmic Y-axis mode fails.
- Message
semilogy: 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.
Only the y-axis is switched to log scale; the x-axis remains linear.
Y log-mode state is subplot-local and does not leak into other subplot axes.
Positive y-values are the meaningful domain for a logarithmic y-axis.
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 X linear and Y logarithmic on its selected subplot axes after plotting succeeds. It does not silently log-transform or overwrite XData/YData.
Examples
Plot an exponential decay on a logarithmic y-axis
t = linspace(0, 10, 200);
semilogy(t, exp(-t));Compare multiple decays on the same axes
t = linspace(0, 10, 200);
h1 = semilogy(t, exp(-t));
set(h1, 'DisplayName', 'exp(-t)');
hold on;
h2 = semilogy(t, exp(-0.3*t));
set(h2, 'DisplayName', 'exp(-0.3t)');
legend;Inspect the y-axis scale after plotting
t = 0:0.1:4;
semilogy(t, exp(t));
ax = gca;
get(ax, 'YScale')Expected output:
ans =
'log'Rendered semilogy example
time = linspace(0, 12, 300);
fast = exp(-0.85*time);
slow = exp(-0.38*time);
h1 = semilogy(time, fast);
set(h1, 'LineWidth', 2, 'DisplayName', 'Fast decay');
hold on;
h2 = semilogy(time, slow, '--');
set(h2, 'LineWidth', 2, 'DisplayName', 'Slow decay');
hold off;
title('Decay Rate Comparison');
xlabel('Time (s)');
ylabel('Normalized response');
legend();
grid on;
Compare this result with other chart types in the plot examples.
Using semilogy with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how semilogy changes the result.
Run a small semilogy example, explain the result, then change one input and compare the output.
FAQ
When is semilogy the right choice over a linear plot?⌄
Whenever the interesting structure lives in multiplicative changes along Y — exponential decay, growth rates, signal attenuation. On a log y-axis, exp(-t) becomes a straight line, which makes decay constants easy to read directly from the slope.
How do I visualize exponential decay and read the time constant?⌄
Plot with semilogy and the decay appears as a straight line. The slope of that line is the decay rate. For exp(-t/tau), the signal drops by a factor of e every tau units along the x-axis.
t = linspace(0, 10, 200);
semilogy(t, exp(-t/3)); % tau = 3
grid on;What about zero or negative y-values on a log y-axis?⌄
They're excluded from rendering since log of zero or negative numbers is undefined. The data handle still stores them, but only positive y-values produce visible points. If your data crosses zero, consider splitting into positive and negative series or using a linear axis.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · 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 semilogy is executed, line by line, in Rust.
- View the source for semilogy 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.