Skip to content

temporian.plot #

plot(
    evsets: InputEventSet,
    indexes: Optional[IndexKeyList] = None,
    features: InputFeatures = None,
    width_px: int = 1024,
    height_per_plot_px: int = 150,
    max_points: Optional[int] = None,
    min_time: Optional[duration_utils.Timestamp] = None,
    max_time: Optional[duration_utils.Timestamp] = None,
    max_num_plots: int = 20,
    style: Union[Style, str] = Style.auto,
    return_fig: bool = False,
    interactive: bool = False,
    backend: Optional[str] = None,
    merge: bool = False,
    font_scale: float = 1,
)

Plots one or several EventSets.

If multiple EventSets are provided, they should all have the same index. The time axis (i.e., horizontal axis) is shared among all the plots. Different features can be plotted independently or on the same plots. Plotting an EventSet without features plots timestamps instead.

When plotting a single EventSet, this function is equivalent to EventSet.plot().

Feature names are used as a legend. When plotting an EventSet without features, the legend is set to be "[sampling]", or to the name of the EventSet, if set.

Examples:

>>> evset = tp.event_set(timestamps=[1, 2, 4],
...     features={"f1": [0, 42, 10], "f2": [10, -10, 20]})

# Plot each feature individually
>>> tp.plot(evset)

# Plots multiple features in the same sub-plot
>>> tp.plot(evset, merge=True)

# Equivalent
>>> evset_2 = tp.event_set([5, 6])
>>> tp.plot([evset, evset_2], merge=True)
>>> tp.plot((evset, evset_2))

# Make the plot interactive
>>> tp.plot(evset, interactive=True)

# Save figure to file
>>> fig = tp.plot(evset, return_fig=True)
>>> fig.savefig("/tmp/fig.png")

# Change drawing style
>>> tp.plot(evset, style="line")

Parameters:

Name Type Description Default
evsets InputEventSet

Single or list of EventSets to plot. Also, tuples can be used to group multiple EventSets in the same sub-plot. Otherwise, all EventSets and features are plotted in separate sub-plots.

required
indexes Optional[IndexKeyList]

The index keys or list of indexes keys to plot. If indexes=None, plots all the available indexes. Indexes should be provided as single value (e.g. string) or tuple of values. Example: indexes="a", indexes=("a",), indexes=("a", "b",), indexes=["a", "b"], indexes=[("a", "b"), ("a", "c")].

None
features InputFeatures

Feature names of the event(s) to plot. Use 'evset.feature_names' for the list of available names. If a feature doesn't exist in an event, it's silently skipped. If None, plots all features of all events.

None
width_px int

Width of the figure in pixel.

1024
height_per_plot_px int

Height of each sub-plot (one per feature) in pixel.

150
max_points Optional[int]

Maximum number of points to plot.

None
min_time Optional[Timestamp]

If set, only plot events after it.

None
max_time Optional[Timestamp]

If set, only plot events before it.

None
max_num_plots int

Maximum number of plots to display. If more plots are available, only plot the first max_num_plots ones and print a warning.

20
style Union[Style, str]

A Style or equivalent string like: line, marker or vline.

auto
return_fig bool

If true, returns the figure object. The figure object depends on the backend.

False
interactive bool

If true, creates an interactive plotting. interactive=True effectively selects a backend that support interactive plotting. Ignored if "backend" is set.

False
backend Optional[str]

Plotting library to use. Possible values are: matplotlib, bokeh. If set, overrides the "interactive" argument.

None
merge bool

If true, plots all features in the same plots. If false, plots features in separate plots. merge=True on event-sets [e1, e2] is equivalent to plotting (e1, e2).

False
font_scale float

Scaling factor for all the fonts.

1