# PlotlyPublisher

## class PlotlyPublisher( figure: go.Figure | go.FigureWidget | None = None, max_points: int = 10_000, flush_interval: float = 0.1, time_window_s: float | None = None, )[source]

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object "(in Python v3.15)")

Plot Measurement/Command data on a Plotly figure, one trace per channel.

Requires the `plot` extra (`pip install "instro[plot]"`).

Create a publisher that plots each channel on a trace named after the channel.

Parameters:
:   - **figure**

      Figure to plot on. A `go.FigureWidget` updates live in a notebook. When
      omitted, the publisher creates a `go.FigureWidget`, displays it right away, and
      shows it again on `close()`.
    - **max_points**

      Points kept per channel; older points drop off the plot.
    - **flush_interval**

      Seconds between writes to the figure.
    - **time_window_s**

      Seconds of data the x axis shows, or `None` (the default) to autoscale. The window starts at the first point and scrolls forward.

Methods

| [`close`](https://dev.nominal.io/instro/ref/library/instro.lib.publishers.plot.PlotlyPublisher.md#instro.lib.publishers.plot.PlotlyPublisher.close "instro.lib.publishers.plot.PlotlyPublisher.close") | Stop the flush thread, write any remaining points to the figure, and clear the buffers. |
| --- | --- |
| [`publish`](https://dev.nominal.io/instro/ref/library/instro.lib.publishers.plot.PlotlyPublisher.md#instro.lib.publishers.plot.PlotlyPublisher.publish "instro.lib.publishers.plot.PlotlyPublisher.publish") | Buffer `data` for the next write to the figure. |

### publish( data: Measurement | Command, **kwargs, ) → None[source]

Buffer `data` for the next write to the figure.

### close() → None[source]

Stop the flush thread, write any remaining points to the figure, and clear the buffers.
