Skip to main content

Bar plot

Bar plot visualizes values as vertical bars. It works on the same kinds of data as Line plot, but is often better suited for vectors and records where you want to compare magnitudes per index or per key.

You select Bar plot in SA Studio by choosing Bar plot from the visualization selector.

//plot: Bar plot
timeout(rfft(winagg(simstream(0.01),256,4)), 8);

This example shows the spectrum of a simulated audio stream as a bar plot.

Interaction

  • Zoom Y-range: click and drag vertically inside the plot.
  • Reset zoom: double-click anywhere in the plot.

Supported data formats

Bar plot supports the same incremental and batch data categories as the other visualizations.

Incremental data types (streaming, with history):

  • Number
  • Vector of Number
  • Record
  • Timeval of Number
  • Timeval of Vector of Number
  • Timeval of Record

Batch data types (full dataset rendered at once, with slider support):

  • Vector of Vector of Number
  • Vector of Record
  • Timeval of Vector of Vector of Number
  • Timeval of Vector of Record
  • Vector of Timeval of Vector of Number
  • Vector of Timeval of Record

For batch types, the plot can show a slider at the top that lets you move through different elements in the batch.

Regular Bar plot

Bar plot works particularly well for vector and record data.

Vectors

For vectors, each element is shown as a bar and the index is used as implicit label:

//plot: Bar plot
[4, 8, 12, 39, 3, 22];

Records

For records, each key becomes the bar label:

//plot: Bar plot
{
"x": 10,
"y": 5,
"z": 13
}

In this case there are three bars labeled x, y, and z.

Plotting batches with slider

When Bar plot receives a batch data type, it can show a slider to move through the batch.

//plot: Bar plot
select vector of x
from Vector x
where x in rfft(winagg(simstream(0.01),256,4))
limit 100;

Here the result is a Vector of Vector of Number (a batch of vectors). Bar plot shows a slider that lets you step through each element in the batch and see its bar representation.


Bar plot in Multi plot

Bar plot can also be used through Multi plot. This is useful when you want to:

  • Combine Bar plots with other visualization types (Line, Scatter, etc.).
  • Control batch behavior and memory per plot.
  • Use Bar plots as part of a dashboard-style layout.

To use Bar plot in Multi plot, you include "Bar plot" as sa_plot or inside sa_plots.

Single Bar plot via Multi plot

You can define a single Bar plot in a Multi plot record to gain access to Multi plot parameters such as batch, labels, and layout.

Generic definition:

{
"sa_plot": "Bar plot",
"labels": ["a", "b", "c"],
"batch": 0
}
  • sa_plot: set to "Bar plot" to create a Bar plot.
  • labels: optional labels to apply to vector elements.
  • batch: if 1, treat incoming data as a batch and render all at once at the end of the stream.

Example: Labeled Bar plot from vector

//plot: Multi plot
{
"sa_plot": "Bar plot",
"labels": ["a", "b", "c", "d"]
};
[4, 8, 12, 3];

Here the four elements in the vector are labeled a, b, c, and d in the plot.

Multiple plots including Bar plot

To combine Bar plots with other plots, use sa_plots:

{
"sa_plots": [
"Line plot",
{ "sa_plot": "Bar plot", "batch": 1 },
"Scatter plot"
],
"labels": ["x", "y"]
}
  • sa_plots: list of plots to create (Line, Bar, Scatter, etc.).
  • batch: here the Bar plot is configured to buffer data and show it as a batch.
  • labels: applied to all plots in the list.

Example OSQL:

//plot: Multi plot
{
"sa_plots": [
{ "sa_plot": "Line plot", "memory": 200 },
{ "sa_plot": "Bar plot", "batch": 1 }
]
};
select [simsig(x), cos(x)]
from Number x
where x in siota(1,200)/10;
  • The Line plot streams and remembers the latest values (controlled by memory).
  • The Bar plot buffers the data (because batch is 1) and can show the final state as a bar representation.

Layout and grid

Like other plots in Multi plot, Bar plots can be positioned using the grid attribute on each plot definition.

{
"sa_plots": [
{ "sa_plot": "Line plot", "grid": { "w": 6, "h": 6, "x": 0 } },
{ "sa_plot": "Bar plot", "grid": { "w": 6, "h": 6, "x": 6 } }
]
}
  • grid.w / grid.h: width and height in grid units.
  • grid.x: horizontal position of the plot.

This lets you place Line and Bar plots side by side, or arrange multiple Bar plots in a dashboard.

Summary

  • Use Bar plot when you want to compare values in vectors or records as bars.
  • Bar plot works with both incremental and batch data; batches can be explored with a slider.
  • Use Bar plot in Multi plot when combining bar visualizations with other plot types, controlling batch behavior per plot, or arranging several plots in a grid layout.