Plotting overview
In Deephaven, plots can be as live as your data. A Deephaven Express figure updates by itself as its table ticks, so you don't poll for new data or rebuild the figure.
Deephaven supports several ways to plot table data. They differ most in how they handle real-time (ticking) tables, which update as new data arrives:
- Deephaven Express, built on top of Plotly Express, plots real-time data directly from Deephaven tables. For examples, see the Deephaven Express plot types.
- Deephaven's built-in plotting API also plots ticking tables natively, but it is no longer under active development.
- Matplotlib and Seaborn plot a copy of the table's data. For ticking tables, the Matplotlib plugin's
TableAnimationclass copies the data and redraws the whole figure on each update. See Limitations of copy-based plotting. - Plotly plots a snapshot, such as a pandas DataFrame from
to_pandas, so the figure doesn't change when the table ticks.
For most plotting tasks, use Deephaven Express. If you'd rather build a chart from the UI without writing code, see Chart Builder.
Plot a ticking table
Let's plot a ticking table. This example uses time_table to create a table that adds a row every second, then plots it with dx.line from Deephaven Express. The line grows each time a new row arrives, with no extra code:
Plotting library support
The table below compares the options for ticking tables and for static tables, such as historical data. Each library name links to its documentation.
| Library | Ticking tables | Static tables | Ease of use | Installation |
|---|---|---|---|---|
| Deephaven Express | Updates natively | Excellent | Excellent | pip install deephaven-plugin-plotly-express* |
| Built-in plotting API (legacy) | Updates natively | Good | Good | Built in |
| Matplotlib | Full redraw | Good | Fair | pip install deephaven-plugin-matplotlib* |
| Seaborn | Full redraw | Good | Excellent | pip install "deephaven-plugin-matplotlib[seaborn]"* |
| Plotly | Snapshot only | Good | Good | Installed with Deephaven Express |
*The ghcr.io/deephaven/server Docker image includes Deephaven Express and the Matplotlib plugin. The machine-learning images don't include them, and neither does a pip install of Deephaven. To add them, see Install and use plugins. The server-slim image runs a Groovy console and has no Python, so it can't use either plugin.
Limitations of copy-based plotting
Matplotlib, Seaborn, and Plotly don't read Deephaven tables directly. They plot a copy of the data, which has two costs:
- Memory and redraw time: Each update copies table data into Python. By default,
TableAnimationandto_pandascopy every column. Pass only the columns you plot to reduce the copy.TableAnimationalso redraws the whole figure on every update, so each update gets slower as the table grows. - Stale figures: A Plotly figure built from a snapshot shows the data as it was when the snapshot was taken. To see new data, you must build the figure again.
Deephaven Express subscribes to table updates directly, so its figures update as the table ticks without copying the whole table into Python on every change.