RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

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.

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

barh — Create horizontal bar charts in MATLAB and RunMat.

barh creates horizontal 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 = barh(Y)
h = barh(Y, width)
h = barh(Y, width, color)
h = barh(Y, style)
h = barh(Y, Name, Value, ...)
h = barh(X, Y)
All supported barh forms
h = barh(Y)
h = barh(Y, width)
h = barh(Y, width, color)
h = barh(Y, style)
h = barh(Y, Name, Value, ...)
h = barh(X, Y)
h = barh(X, Y, width)
h = barh(X, Y, width, color)
h = barh(X, Y, style)
h = barh(X, Y, Name, Value, ...)

Inputs

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

NameTypeDescription
hNumericArrayBar graphics handle or handle row vector, with one handle per plotted series.

Errors

IdentifierWhenMessage
RunMat:barh:InvalidArgumentHorizontal bar input arrays, style tokens, or name/value arguments are invalid.barh: invalid argument
RunMat:barh:InternalRenderer/GPU conversion fails while building horizontal bar geometry.barh: internal operation failed

How barh works

  • Vector inputs create a single horizontal bar series with implicit category positions on the y-axis.
  • Matrix inputs support grouped and stacked horizontal bar 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 thickness 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 preserves the same fast GPU-backed rendering path as bar when inputs and style options can be handled by the shared bar vertex packer.

Does RunMat run barh on the GPU?

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

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

The builtin is a plotting sink and fusion barrier.

GPU memory and residency

barh preserves floating GPU residency where the shared 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.

Examples

Create a basic horizontal bar chart from a vector

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

Create grouped horizontal bars from a matrix

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

Create stacked horizontal bars

Y = [8 15 25; 30 35 40; 50 55 62];
barh(Y, 'stacked');

Style a horizontal bar object and label it for the legend

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

Using barh with coding agents

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

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

FAQ

How is barh different from bar?⌄

barh draws the same bar data horizontally. The y-axis is the category axis and the x-axis shows the numeric values.

bar([3 5 2 9]);   % vertical bars
barh([3 5 2 9]);  % horizontal bars
How do I create grouped vs stacked horizontal bar charts?⌄

Pass a matrix to barh. By default, each row becomes a group with side-by-side horizontal bars. To stack them instead, pass 'stacked'.

Y = [3 5 2; 4 6 1; 5 4 3];
barh(Y);            % grouped
barh(Y, 'stacked'); % stacked
Can barh use explicit category positions?⌄

Yes. Pass X and Y like MATLAB's barh(X,Y) form. The X values label the category positions on the vertical axis.

x = [1980 1990 2000];
y = [10 20 30];
barh(x, y);

Related Plotting functions

2D Charts

area · bar · 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 · axes · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · text · textscatter · textscatter3 · triplot · waitbar · 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

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how barh is executed, line by line, in Rust.

  • View the source for barh in Rust on GitHub
  • Learn how the RunMat 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 blazing on any GPU. It is licensed under the Apache 2.0 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
  • How barh works
  • Does RunMat run barh on the GPU?
  • GPU memory and residency
  • Examples
  • Create a basic horizontal bar chart from a vector
  • Create grouped horizontal bars from a matrix
  • Create stacked horizontal bars
  • Style a horizontal bar object and label it for the legend
  • Using barh with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Open-source implementation
  • About RunMat