Use sparklines in the Record block or Simulation Data Inspector to easily plot and view many signals at once. The sparklines visualization adds a sparkline for each signal you plot. Once sparklines fill the visible space, a scroll bar allows you to continue plotting more signals.
This example shows how to add a sparklines visualization to your layout in the Simulation Data Inspector, plot signals, and adjust the appearance of the sparklines. The Record block uses a sparklines visualization by default and has the same options for modifying the sparkline appearance.
For this example, simulate the
sldemo_fuelsys model to create a run of data to plot in the Simulation Data Inspector. Then, open the Simulation Data Inspector using the
open_system('sldemo_fuelsys'); out = sim('sldemo_fuelsys');
By default, the Simulation Data Inspector shows a single time plot. To replace the time plot with a sparklines visualization, open the Layout menu and click Edit View to open the Visualization Gallery.
From the Visualization Gallery, drag and drop the Sparklines icon onto the time plot.
The Simulation Data Inspector groups logged data by its domain, which can indicate the type or source of the data. Expand the Signals group. You can add sparklines for the signals one by one by selecting the check box next to each signal you want to plot, or you can select a group of signals to drag and drop onto the plot. Each signal is shown on its own sparkline.
If you want to view more than one signal in a single sparkline, you can drag the signal line from one sparkline onto another. The sparkline for the signal you moved disappears, and both signals are shown together in the sparkline where you dragged the signal. For example, drag the
ego signal into the top sparkline.
You can also reorder the sparklines by dragging the signal line and dropping it between two sparklines where you want that signal to appear. For example, drag the
ego signal out of the top sparkline and drop it in between the first and second sparklines.
You can add cursors to your plot to see the value for each signal at a given time. You can also use the replay controls with sparklines to inspect how the signal values change relative to each other over time. When you pan or zoom in a given sparkline, all other sparklines remain synchronized.
You can adjust the minimum height for a sparkline using the Visualization Settings. For example, increase the minimum height to
130 px. The values you specify in the Visualization Settings are specific to a single sparklines visualization.
With the larger minimum height, all the sparklines are not visible at once, and a scroll bar allows you to view all the signals. To scroll down, select the scroll bar with your mouse and drag.
During simulation, plotted signals stream data to the sparklines visualization. You can control how the signal data is displayed as well as how and when the sparklines update using the Update mode and Time span settings in the Visualization Settings. Change Update mode to
Scroll and set Time span to
100. Then, simulate the model again.
out = sim('sldemo_fuelsys');
By default, the Simulation Data Inspector automatically moves the archive to the previous run and plots signals from the current simulation in the place of plotted signals from the prior simulation. To inspect a signal of interest during simulation, you can freeze the display using the Freeze display button.
Alternatively, you could use a trigger to control when the sparklines update. For more information, see Control Display of Streaming Data Using Triggers