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 bar works in 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 memory and 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
values = [3 5 2 9];
bar(values)Related functions to explore
These functions work well alongside bar. Each page has runnable examples you can try in the browser.
contour, contourf, hist, mesh, meshc, plot, scatter, scatter3, stairs, surf, surfc
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how bar works, line by line, in Rust.
- View bar.rs on GitHub
- Learn how the runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.