Skip to main content

Line plot

Line plot visualizes one or more series as lines in a diagram. It is the most common way to inspect numeric streams over time or over an index.

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

//plot: Line plot
simsig(siota(1,200)/10);

This example plots a single series from the function simsig.

Interaction

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

Supported data formats

Line 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
  • Arrays of Rank 1

Batch data types (full dataset rendered at once):

  • 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
  • Arrays of Rank 2 (MxN) where M is series and N are points in that series

For batch types, the full graph is rendered at once without a scrolling history.

Multiple series in one Line plot

Line plot can show several series in the same diagram.

When the result is a vector of numbers, each element in the vector is treated as a separate series:

//plot: Line plot
select [simsig(x), cos(x)]
from Number x
where x in siota(1,200)/10;

When the result is a record, each key becomes the series label:

//plot: Line plot
select {
"sim_sig(x)": simsig(x),
"cos(x)": cos(x)
}
from Number x
where x in range(200)/10
order by x;

Each key in the record ("sim_sig(x)", "cos(x)") is shown as a separate line with its own legend entry.

You can click the colored square next to a series label in the legend to toggle the visibility of that series.

Plotting batches

When line plot receives a batch data type, it plots the entire batch in one go.

Example using Vector of Record:

//plot: Line plot
select Vector of {"sim_sig": simsig(x), "cos": cos(x)}
from Number x
where x in range(200)/10
order by x;

In this case, line plot draws a full graph using all the values in the batch.


Line plot in Multi plot

Line plot can also be used through Multi plot. This allows you to:

  • Combine Line plots with other visualization types.
  • Control memory and batch behavior on a per-plot basis.
  • Route different dimensions or tagged streams into separate Line plots.
  • Arrange plots in a grid layout.

To use Line plot in Multi plot, you define a JSON record for sa_plot or put "Line plot" into a sa_plots list.

Single Line plot via Multi plot

Even if you only need a single Line plot, you can still use Multi plot to get more configuration options.

Generic single-plot definition:

{
"sa_plot": "Line plot",
"labels": ["series1", "series2"],
"memory": 200,
"batch": 0
}
  • sa_plot: set to "Line plot" to use the Line plot visualization.
  • labels: optional labels for the dimensions when the input is a vector.
  • memory: how many values to keep when streaming incremental data.
  • batch: if 1, buffer values until the end and then render the batch.

Example: Two series in a Multi-plot Line plot

//plot: Multi plot
{
"sa_plot": "Line plot",
"labels": ["simsig", "cos"],
"memory": 200
};
select [simsig(x), cos(x)]
from Number x
where x in siota(1,200)/10;

Here:

  • The query returns a two-dimensional vector for each x.
  • labels names the dimensions so they appear as "simsig" and "cos" in the legend.
  • memory controls how many recent points are kept in view.

Multiple Line plots and mixed plots

To define multiple plots (for example, several Line plots or a mix of Line and other plots), use sa_plots:

{
"sa_plots": [
"Line plot",
{ "sa_plot": "Line plot", "memory": 500 },
"Scatter plot"
],
"labels": ["x", "y"]
}
  • sa_plots: list of plots. Each entry can be a string (e.g., "Line plot") or a full sa_plot record.
  • Attributes outside sa_plots (like labels) are applied to all plots.

Example OSQL combining Line and other plots:

//plot: Multi plot
{
"sa_plots": [
{ "sa_plot": "Line plot", "memory": 200 },
{ "sa_plot": "Line plot", "memory": 200 }
],
"labels": ["simsig", "cos"]
};
select [simsig(x), cos(x)]
from Number x
where x in siota(1,200)/10;

Both Line plots receive the same data and can be individually zoomed and configured.

Routing dimensions to separate Line plots

In more advanced Multi plot configurations, you can route different dimensions or labeled fields to different plots by using labels and plot-specific attributes. A common pattern is:

{
"labels": ["x", "y"],
"sa_plots": [
{ "sa_plot": "Line plot", "labels": ["x"] },
{ "sa_plot": "Line plot", "labels": ["y"] }
]
}

Conceptually this means:

  • The first Line plot only shows the series labeled "x".
  • The second Line plot only shows the series labeled "y".

Your OSQL query would then produce a vector or record where these labels/dimensions are present.

Layout and grid

When using Multi plot, you can arrange Line plots in a grid using grid on each plot.

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

This lets you position multiple Line plots side by side or in other layouts in the plotting pane.

Summary

  • Use Line plot to visualize one or more series over time or index.
  • Input can be numbers, vectors, or records; vectors and records naturally create multiple series.
  • Batch data types render entire graphs in one go.
  • Use Line plot in Multi plot for more advanced scenarios: controlling memory and batch behavior per plot, combining plots, routing specific series to separate Line plots, and arranging plots in a grid layout.