LensPy Package Reference

class lenspy.DynamicPlot(fig: plotly.graph_objs._figure.Figure, max_points: Optional[int] = 10240, agg_func: Optional[Union[str, List, Dict]] = 'first', agg_args: Tuple = (), agg_kwargs: Dict = {})

Bases: object

property max_points
refine_plot(relayoutData) → plotly.graph_objs._figure.Figure
set_aggregator(agg_func: Optional[Union[str, List, Dict]] = 'first', agg_args: Tuple = (), agg_kwargs: Dict = {})

Updates the aggregator.

Parameters
  • agg_func (callable or str supported by pandas.core.groupby.DataFrameGroupby.aggregate()) – The function to aggregate the trace with. Defaults to “first”

  • agg_args (tuple) – Arguments to pass to agg_func

  • agg_kwargs (dict) – Keyword arguments to pass to agg_func

show(*args, **kwargs)

Displays the plot. All arguments are passed to dash.Dash.run_server()

class lenspy.TraceManager(trace: plotly.basedatatypes.BaseTraceType, max_points: int, agg_func: Union[str, List, Dict], agg_args: Tuple, agg_kwargs: Dict)

Bases: object

Manages the content of a Trace based on the viewport of the plotly.graph_objects.Figure.

Configure the number of points to show at any given time using :param max_points:. agg_func, agg_args, and agg_kwargs are passed directly to pd.core.groupby.DataFrameGroupby.aggregate().

Parameters
  • trace (class:plotly.basedatatypes.BaseTraceType) – The trace to be managed.

  • max_points (int, optional) – The maximum number of points to display at any given point, defaults to 10,240

  • agg_func (str or callable) – The function to aggregate the trace with

  • agg_args (tuple) – Arguments to pass to agg_func

  • agg_kwargs (dict) – Keyword arguments to pass to agg_func

extract_df(trace: plotly.basedatatypes.BaseTraceType) → Tuple[pandas.core.frame.DataFrame, List[str]]

Extracts the data passed to the trace and returns a pd.DataFrame.

Parameters

trace (class:plotly.basedatatypes.BaseTraceType) – The trace to be managed

Returns

Tuple containing the pd.DataFrame and a list of the dimensions to include in the plot

Return type

tuple

refresh(view_port: Dict[str, Union[int, float]] = {})

Updates the trace based on the viewport.

Parameters

view_port (dict, optional) – Viewport to update the trace with. Defaults to {}