bar — Render MATLAB-compatible bar charts.
bar(y) plots the values of y as vertical bars with MATLAB-compatible defaults. RunMat matches MATLAB's behaviour for 1-D inputs: categories are labelled 1,2,...,n, grid lines are enabled, and the current figure receives a descriptive title and axis labels.
How does the bar function behave in MATLAB / RunMat?
- Inputs must be numeric vectors. Scalars produce a single bar; empty inputs raise MATLAB-style errors.
- Single-precision gpuArray inputs stay on the device and stream directly into the shared renderer for zero-copy plotting when WebGPU is available. Other data gathers automatically.
- Future work will add grouped/stacked variants; this initial builtin focuses on the common
bar(y)form used throughout the standard library tests.
GPU residency
bar terminates fusion graphs. Single-precision gpuArray vectors reuse provider buffers via the shared WebGPU context; other precisions gather to the host before plotting.
Example of using bar in MATLAB / RunMat
values = [3 5 2 9];
bar(values)Source & Feedback
- Source code: `crates/runmat-runtime/src/builtins/plotting/ops/bar.rs`
- Found a bug? Open an issue with a minimal reproduction.