RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • addpoints
    • ancestor
    • animatedline
    • area
    • autumn
    • axes
    • axis
    • bar
    • barh
    • bone
    • box
    • caxis
    • cla
    • clf
    • clim
    • colorbar
    • colorcube
    • colormap
    • colororder
    • contour
    • contour3
    • contourf
    • cool
    • copper
    • copyobj
    • cylinder
    • daspect
    • datacursormode
    • dataTipTextRow
    • drawnow
    • errorbar
    • fcontour
    • figure
    • fill
    • fill3
    • findobj
    • fsurf
    • gca
    • gcf
    • get
    • gobjects
    • gray
    • grid
    • groot
    • heatmap
    • hgload
    • hgsave
    • hidden
    • hist
    • histogram
    • histogram2
    • hold
    • hot
    • image
    • imagesc
    • imshow
    • inferno
    • isgraphics
    • ishandle
    • jet
    • legend
    • line
    • lines
    • linkaxes
    • loglog
    • magma
    • mesh
    • meshc
    • openfig
    • opengl
    • pan
    • parula
    • patch
    • pie
    • pink
    • plasma
    • plot
    • plot3
    • plotmatrix
    • plotyy
    • polarhistogram
    • polarplot
    • polarscatter
    • print
    • quiver
    • quiver3
    • ribbon
    • saveas
    • savefig
    • scatter
    • scatter3
    • semilogx
    • semilogy
    • set
    • sgtitle
    • shading
    • sphere
    • spring
    • stackedplot
    • stairs
    • stem
    • subplot
    • subtitle
    • summer
    • suptitle
    • surf
    • surfc
    • text
    • textscatter
    • textscatter3
    • title
    • triplot
    • turbo
    • view
    • viridis
    • waitbar
    • winter
    • wordcloud
    • xlabel
    • xlim
    • xline
    • xscale
    • xtickangle
    • xtickformat
    • xticklabels
    • xticks
    • ylabel
    • ylim
    • yline
    • yscale
    • ytickangle
    • ytickformat
    • yticklabels
    • yticks
    • zlabel
    • zlim
    • zoom

bar — Create bar charts in MATLAB and RunMat.

bar creates vertical bar charts from scalar, vector, or matrix Y data, optionally at explicit X positions. It returns one bar handle per plotted series and supports grouped and stacked forms through the shared plotting handle-property system.

Syntax

h = bar(Y)
h = bar(Y, width)
h = bar(Y, width, color)
h = bar(Y, style)
h = bar(Y, Name, Value, ...)
h = bar(X, Y)
All supported bar forms
h = bar(Y)
h = bar(Y, width)
h = bar(Y, width, color)
h = bar(Y, style)
h = bar(Y, Name, Value, ...)
h = bar(X, Y)
h = bar(X, Y, width)
h = bar(X, Y, width, color)
h = bar(X, Y, style)
h = bar(X, Y, Name, Value, ...)

Inputs

Y
Type
NumericArray
Required
Yes
Description
Bar heights as a vector or matrix.
width
Type
NumericScalar
Required
Yes
Default
0.8
Description
Fraction of available category space occupied by each bar.
color
Type
StyleSpec
Required
Yes
Description
Color shorthand or color name for all bars.
style
Type
StyleSpec
Required
Yes
Description
Layout/style token such as 'stacked' or color shorthand.
props
Type
Any
Required
Variadic
Description
Name/value style arguments.
X
Type
NumericArray
Required
Yes
Description
Category positions for bars.
NameTypeRequiredDefaultDescription
YNumericArrayYes—Bar heights as a vector or matrix.
widthNumericScalarYes0.8Fraction of available category space occupied by each bar.
colorStyleSpecYes—Color shorthand or color name for all bars.
styleStyleSpecYes—Layout/style token such as 'stacked' or color shorthand.
propsAnyVariadic—Name/value style arguments.
XNumericArrayYes—Category positions for bars.

Returns

h
Type
NumericArray
Description
Bar graphics handle or handle row vector, with one handle per plotted series.
NameTypeDescription
hNumericArrayBar graphics handle or handle row vector, with one handle per plotted series.

Errors

RunMat:bar:InvalidArgument
When
Bar input arrays, style tokens, or name/value arguments are invalid.
Message
bar: invalid argument
RunMat:bar:Internal
When
Renderer/GPU conversion fails while building bar geometry.
Message
bar: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than one output is requested from a coordinate chart constructor.
Message
plotting: too many output arguments
IdentifierWhenMessage
RunMat:bar:InvalidArgumentBar input arrays, style tokens, or name/value arguments are invalid.bar: invalid argument
RunMat:bar:InternalRenderer/GPU conversion fails while building bar geometry.bar: internal operation failed
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

Vector inputs create a single bar series with implicit category positions.

Matrix inputs support grouped and stacked bar-style rendering workflows.

Matrix Y returns a row vector containing one opaque bar handle per series; scalar and vector Y return one handle.

X and Y accept all eight integer classes. Exact integer X labels and uniqueness are preserved before conversion into client graphics coordinates.

The positional bar width defaults to 0.8 and, like the LineWidth property, accepts real numeric scalars including every integer class.

Display names, bar width, and face color participate in the shared plotting object/property model.

RunMat prefers GPU-backed rendering when supported input/layout combinations are present, while preserving the same bar semantics on fallback paths.

Rendering and residency

bar keeps floating gpuArray Y data on the shared WGPU geometry path where supported. Integer gpuArray Y data gathers exactly on the client before the deliberate floating graphics conversion.

bar preserves floating GPU residency where the bar geometry pipeline can consume exported buffers directly. Integer GPU data gathers once through its owning provider so native integer buffers are never reinterpreted by the floating vertex shader.

Floating single and double Y data can use the shared WGPU vertex-packing path.

All eight resident integer classes use exact client gather before the explicit floating graphics boundary.

Direct floating rendering precisions

single

double

Coordinate broadcasting

none

Runtime contract and boundaries

The result is a host graphics handle, not a numeric coordinate array. Coordinate parsing, native source storage, series expansion, style validation and graphics state use the existing plotting owners. Numeric handle aliases are resolved at Runtime, so static inference does not guess that a scalar coordinate denotes axes. The line, bar, barh and area constructors may return a row of handles; the other identities return the first created handle. More than one language output is rejected before chart work.

Single and double source data use their native storage where the chart has typed source properties; all eight integer classes use the declared identity-specific coordinate/control rules. Rendering is an explicit floating geometry boundary. In particular errorbar, bar, barh and area convert client graphics data to floating geometry; this does not certify exact integer-valued rendered pixels. Complex, logical, sparse, empty and matrix admission is decided by each existing numerical/shape parser, not by this shared ingress. Unsupported representations raise the existing parser diagnostic rather than being assumed fully MATLAB compatible.

Direct GPU rendering is conditional on the actual owning provider, live physical input leases, floating class/storage, supported shape/style, compatible shared device exports and native plotting feature availability. A pre-effect unavailable direct route may take the existing client path; a failed or partially completed export/reduction/emission is terminal and never permission to replay on the host. Source-property reads and figure persistence can perform later explicit readback. There is no elementwise/reduction fusion, distributed execution or portable numeric provider kernel for these graphics sinks.

User-interface capability and host-callback effects describe graphics creation/presentation, not numeric purity. Portable Runtime linking and an ordinary execution stack allow Native and Wasm ingress; actual presentation requires the installed graphics host. Retained chart data, style metadata, renderer buffers and serialization are separate lifetimes. Current chart scratch/state has no complete finite allocation owner: Managed policy is rejected before argument extraction, gather or chart mutation through the existing HostAllocationReceipt authority. Ordinary Unbounded resident and host routes remain available. Issuer/policy/cancellation are fenced before publication and errors carry Never replay. This refusal, unbounded host loops, provider/renderer-private allocations, full property parity and measured performance remain open obligations; Incomplete/Partial is not a completion certificate.

Supported representations and remaining forms

Y and optional X accept host Num/Int scalars via NumericInput as well as real single/double/native-integer Tensors; logical, complex and sparse arrays are not implemented by BarInput. Empty input and unsupported rank/shape are rejected. Exact integer X values are retained for labels and uniqueness validation before geometry conversion. Scalar/vector input creates one series; a matrix uses the existing category/orientation rules and returns a row of series handles.

Positional width, grouped/stacked layout, optional explicit X, color and supported shared bar name/value controls retain the existing BarStyle parser and range diagnostics. BarWidth defaults to 0.8. Floating Y may retain a same-owner GPU source; integer Y and resident X use exact client gather. Stacked GPU bounds currently read back source values for accumulation, so residency preservation does not imply a zero-readback operation. Public Bar data-property parity remains incomplete; Type, Parent, Children, FaceColor, BarWidth and DisplayName are the supported getter fields.

Examples

Create a basic bar chart from a vector

values = [3 5 2 9];
bar(values);

Create grouped bars from a matrix

Y = [3 5 2; 4 6 1; 5 4 3];
bar(Y);

Style a bar object and label it for the legend

h = bar([2 4 1 5]);
set(h, 'FaceColor', 'g', 'DisplayName', 'counts');
legend;

Grouped category comparison

categories = {'Q1', 'Q2', 'Q3', 'Q4'};
revenue = [42 51 63 58; 38 45 52 61; 29 34 48 55];

bar(revenue');
title('Quarterly Revenue by Region');
xlabel('Quarter');
ylabel('Revenue ($M)');
legend('North', 'South', 'West');
grid on;

Rendered bar example

categories = {'Q1', 'Q2', 'Q3', 'Q4'};
revenue = [42 51 63 58; 38 45 52 61; 29 34 48 55];

bar(revenue');
title('Quarterly Revenue by Region');
xlabel('Quarter');
ylabel('Revenue ($M)');
legend('North', 'South', 'West');
grid on;
Expected output:
Quarterly revenue for three regions rendered as a grouped MATLAB bar chart in RunMat

Compare this result with other chart types in the plot examples.

Using bar with coding agents

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

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

FAQ

How do I create grouped vs stacked bar charts?⌄

Pass a matrix to bar. By default, each row becomes a group with side-by-side bars (one per column). To stack them instead, pass 'stacked' as the second argument.

Y = [3 5 2; 4 6 1; 5 4 3];
bar(Y);            % grouped (default)
bar(Y, 'stacked'); % stacked
Can I make horizontal bar charts?⌄

Use barh instead of bar. It takes the same inputs but draws bars horizontally. The y-axis becomes the category axis and the x-axis shows values.

barh([3 5 2 9]);
How do I set custom category labels on the x-axis?⌄

After calling bar, use set(gca, 'XTickLabel', ...) to replace the default numeric labels with strings.

bar([4 7 2]);
set(gca, 'XTickLabel', {'Q1', 'Q2', 'Q3'});

The label count should match the number of bar groups.

Related Plotting functions

2D Charts

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

addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom

More plotting resources

  • Choosing the right plot type
  • Styling plots and axes
  • Plot replay and export
  • Complete plotting guide

Source you can read

Every RunMat function's source is public. Read exactly how bar is executed, line by line, in Rust.

  • View the source for bar in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Rendering and residency
  • Direct floating rendering precisions
  • Coordinate broadcasting
  • Runtime contract and boundaries
  • Supported representations and remaining forms
  • Examples
  • Create a basic bar chart from a vector
  • Create grouped bars from a matrix
  • Style a bar object and label it for the legend
  • Grouped category comparison
  • Rendered bar example
  • Using bar with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Source you can read
  • About RunMat