Skip to main content
Version: Python

plot_xy

The plot_xy method creates XY series plots using data from tables.

Syntax

plot_xy(
series_name: str,
t: Union[Table, SelectableDataSet],
x: Union[str, list[int], list[float], list[DateTime]],
y: Union[str, list[int], list[float], list[DateTime]],
x_low: Union[str, list[int], list[float], list[DateTime]] = None,
x_high: Union[str, list[int], list[float], list[DateTime]] = None,
y_low: Union[str, list[int], list[float], list[DateTime]] = None,
y_high: Union[str, list[int], list[float], list[DateTime]] = None,
function: Callable = None,
by: list[str] = None,
x_time_axis: bool = None,
y_time_axis: bool = None,
) -> Figure

Parameters

ParameterTypeDescription
series_namestr

The name you want to use to identify the series on the plot itself.

tUnion[Table, SelectableDataSet]

The table (or other selectable data set) that holds the data to be plotted.

xUnion[str, list[int], list[float], list[DateTime]]

The name of the column of data to be used for the X value.

yUnion[str, list[int], list[float], list[DateTime]]

The name of the column of data to be used for the Y value.

x_low optionalUnion[str, list[int], list[float], list[DateTime]]

Lower X error bar.

x_high optionalUnion[str, list[int], list[float], list[DateTime]]

Upper X error bar.

y_low optionalUnion[str, list[int], list[float], list[DateTime]]

Lower Y error bar.

y_high optionalUnion[str, list[int], list[float], list[DateTime]]

Upper Y error bar.

function optionalCallable

A built-in or user-defined function.

by optionallist[str]

Columns that hold grouping data.

x_time_axis optionalbool

Whether to treat the X values as times.

y_time_axis optionalbool

Whether to treat the Y values as times.

Returns

An XY series plot with a single axes.

Examples

The following example plots data from a Deephaven table.

from deephaven import read_csv
from deephaven.plot.figure import Figure

source = read_csv(
"https://media.githubusercontent.com/media/deephaven/examples/main/MetricCentury/csv/metriccentury.csv"
)

plot_single = (
Figure()
.plot_xy(
series_name="Distance",
t=source.where(filters=["SpeedKPH > 0"]),
x="Time",
y="DistanceMeters",
)
.show()
)