{
"title": "semilogy",
"category": "plotting",
"keywords": [
"semilogy",
"logarithmic y-axis",
"semilog plot",
"matlab semilogy",
"exponential plot"
],
"summary": "Plot data with a logarithmic y-axis for exponential trends, decay curves, and MATLAB `semilogy` workflows.",
"requires_feature": null,
"tested": {
"unit": "builtins::plotting::semilogy::tests"
},
"description": "`semilogy` uses the standard RunMat line-plot path and then marks the active y-axis as logarithmic. It is a natural fit for exponential decay, growth curves, and magnitude data that spans orders of magnitude along Y while preserving MATLAB `semilogy` call forms.",
"behaviors": [
"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."
],
"examples": [
{
"description": "Plot an exponential decay on a logarithmic y-axis",
"input": "t = linspace(0, 10, 200);\nsemilogy(t, exp(-t));"
},
{
"description": "Compare multiple decays on the same axes",
"input": "t = linspace(0, 10, 200);\nh1 = semilogy(t, exp(-t));\nset(h1, 'DisplayName', 'exp(-t)');\nhold on;\nh2 = semilogy(t, exp(-0.3*t));\nset(h2, 'DisplayName', 'exp(-0.3t)');\nlegend;"
},
{
"description": "Inspect the y-axis scale after plotting",
"input": "t = 0:0.1:4;\nsemilogy(t, exp(t));\nax = gca;\nget(ax, 'YScale')",
"output": "ans =\n 'log'"
}
],
"faqs": [
{
"question": "When is semilogy the right choice over a linear plot?",
"answer": "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."
},
{
"question": "How do I visualize exponential decay and read the time constant?",
"answer": "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.\n\n```matlab\nt = linspace(0, 10, 200);\nsemilogy(t, exp(-t/3)); % tau = 3\ngrid on;\n```"
},
{
"question": "What about zero or negative y-values on a log y-axis?",
"answer": "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."
}
],
"links": [
{
"label": "plot",
"url": "./plot"
},
{
"label": "semilogx",
"url": "./semilogx"
},
{
"label": "loglog",
"url": "./loglog"
},
{
"label": "axis",
"url": "./axis"
},
{
"label": "Choosing the right plot type",
"url": "/docs/plotting/choosing-the-right-plot-type"
},
{
"label": "Styling plots and axes",
"url": "/docs/plotting/styling-plots-and-axes"
},
{
"label": "Plot replay and export",
"url": "/docs/plotting/plot-replay-and-export"
},
{
"label": "Complete plotting guide",
"url": "/blog/matlab-plotting-guide"
}
],
"source": {
"label": "`crates/runmat-runtime/src/builtins/plotting/ops/semilogy.rs`",
"url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/plotting/ops/semilogy.rs"
}
}