runmat-runtime 0.4.5

Core runtime for RunMat with builtins, BLAS/LAPACK integration, and execution APIs
Documentation
{
  "title": "axis",
  "category": "plotting",
  "keywords": [
    "axis",
    "axis limits",
    "axis equal",
    "axis tight",
    "matlab axis"
  ],
  "summary": "Control axis limits, aspect behavior, and automatic fitting with MATLAB `axis` semantics.",
  "requires_feature": null,
  "tested": {
    "unit": "builtins::plotting::cmds"
  },
  "description": "`axis` is the compact plotting command for changing axes limits and aspect behavior. In RunMat it operates on the active axes state, so it is naturally used after plotting calls or within a selected subplot to reproduce MATLAB `axis` workflows such as `axis([xmin xmax ymin ymax])`, `axis equal`, `axis auto`, and `axis tight`.",
  "behaviors": [
    "Passing a four-element numeric vector sets `[xmin xmax ymin ymax]` directly.",
    "`axis equal` enables equal aspect behavior on the current axes.",
    "`axis auto` clears explicit limits and returns to automatic fitting.",
    "`axis tight` uses data-driven fitting behavior while leaving figure-local plot contents unchanged.",
    "Axis settings are subplot-local because they act on the active axes state."
  ],
  "examples": [
    {
      "description": "Set explicit x and y limits",
      "input": "plot(0:0.1:10, sin(0:0.1:10));\naxis([0 10 -1 1]);"
    },
    {
      "description": "Force equal axis scaling",
      "input": "t = linspace(0, 2*pi, 200);\nplot(cos(t), sin(t));\naxis equal;"
    },
    {
      "description": "Return to automatic fitting inside a subplot",
      "input": "subplot(1, 2, 1);\nplot(1:5, [1 4 2 5 3]);\naxis tight;\nsubplot(1, 2, 2);\nplot(1:5, [5 4 3 2 1]);\naxis auto;"
    }
  ],
  "faqs": [
    {
      "question": "How do I get equal aspect ratio so circles look like circles?",
      "answer": "Call `axis equal` after your plot command. This forces one unit on x to equal one unit on y in screen space. Without it, a circle drawn with `plot(cos(t), sin(t))` will appear as an ellipse if the figure isn't perfectly square.\n\n```matlab\nt = linspace(0, 2*pi, 200);\nplot(cos(t), sin(t));\naxis equal;\n```"
    },
    {
      "question": "How do I set manual axis limits?",
      "answer": "Pass a four-element vector: `axis([xmin xmax ymin ymax])`. For 3-D plots, use six elements: `axis([xmin xmax ymin ymax zmin zmax])`. This overrides auto-fitting until you call `axis auto` to return to data-driven limits."
    },
    {
      "question": "What does axis tight actually do?",
      "answer": "`axis tight` fits the axes limits snugly around the plotted data with no padding. Compare to `axis auto`, which may add margin for readability. Use `tight` when you want the data to fill the entire axes area — useful for image-like plots or when whitespace is wasted space."
    }
  ],
  "links": [
    {
      "label": "grid",
      "url": "./grid"
    },
    {
      "label": "box",
      "url": "./box"
    },
    {
      "label": "subplot",
      "url": "./subplot"
    },
    {
      "label": "plot",
      "url": "./plot"
    },
    {
      "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/cmds.rs`",
    "url": "https://github.com/runmat-org/runmat/blob/main/crates/runmat-runtime/src/builtins/plotting/ops/cmds.rs"
  }
}