RunMat
GitHub

semilogx — Plot data with a logarithmic x-axis using MATLAB-compatible semilogx call patterns.

semilogx creates line plots like plot and configures the active axes to logarithmic scaling on X. It follows MATLAB-compatible argument forms, axes targeting, and handle behavior.

Syntax

h = semilogx(Y)
h = semilogx(X, Y)
h = semilogx(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:semilogx:PlotFailedUnderlying plot rendering/parsing fails while building the semilog plot.semilogx: plot operation failed
RunMat:semilogx:LogAxisFailedApplying logarithmic X-axis mode fails.semilogx: failed to apply logarithmic axis mode

How semilogx works

  • The builtin returns the same kind of numeric line handle as plot.
  • Only the x-axis is switched to log scale; the y-axis remains linear.
  • Axes log-mode state is subplot-local, so semilogx on one subplot does not force every axes in the figure into log mode.
  • Positive x-values are the meaningful domain for a logarithmic axis, even though the plotted line object still preserves the original data handle semantics.

Examples

Plot a frequency response with a logarithmic x-axis

f = logspace(0, 4, 200);
mag = 1 ./ sqrt(1 + (f / 200).^2);
semilogx(f, mag);

Compare two responses on the same semilog x-axis

f = logspace(0, 4, 200);
h1 = semilogx(f, 1 ./ sqrt(1 + (f / 200).^2));
set(h1, 'DisplayName', 'low-pass');
hold on;
h2 = semilogx(f, (f / 200) ./ sqrt(1 + (f / 200).^2));
set(h2, 'DisplayName', 'high-pass');
legend;

Verify the x-axis scale through handle/property workflows

f = logspace(1, 3, 50);
semilogx(f, log10(f));
ax = gca;
get(ax, 'XScale')

Expected output:

ans =
    'log'

Using semilogx with coding agents

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

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

FAQ

When should I use semilogx instead of plot?

Use semilogx when your x-data spans several orders of magnitude and you care about relative differences across that range. Frequency response curves (Bode magnitude plots) are the classic example — frequencies from 1 Hz to 100 kHz are unreadable on a linear axis but spread evenly on a log scale.

How is semilogx different from calling plot and then switching the x-axis to log?

Functionally identical. semilogx(x, y) is shorthand for plot(x, y) followed by set(gca, 'XScale', 'log'). The convenience form just does both in one call and makes intent clearer when reading code.

What happens if my x-data contains zero or negative values?

Logarithmic axes only render positive values. Zero and negative x-values are silently excluded from the rendered line — the data handle still holds them, but they won't appear on the plot. Filter your data to the positive domain if you need a continuous curve.

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · 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 semilogx 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.