BasePlot#

class pyopenms_viz._core.BasePlot(data: DataFrame, config: BasePlotConfig = None, **kwargs)#

Bases: ABC

This class shows functions which must be implemented by all backends

__init__(data: DataFrame, config: BasePlotConfig = None, **kwargs)#
__repr__()#

Return repr(self).

__weakref__#

list of weak references to the object

_check_and_aggregate_duplicates()#

Check if duplicate data is present and aggregate if specified. Properly handles data types and only aggregates relevant columns

_copy_config_attributes()#

Copy attributes from config to plot object

property _interactive: bool#

Whether the plot is interactive. Must be overridden by subclasses

abstract property _kind: str#

The kind of plot to assemble. Must be overridden by subclasses.

abstractmethod _modify_x_range(x_range: Tuple[float, float], padding: Tuple[float, float] | None = None)#

Modify the x-axis range.

Parameters:
  • x_range (Tuple[float, float]) – The desired x-axis range.

  • padding (Tuple[float, float] | None, optional) – The padding to be applied to the x-axis range, in decimal percent. Defaults to None.

abstractmethod _modify_y_range(y_range: Tuple[float, float], padding: Tuple[float, float] | None = None)#

Modify the y-axis range.

Parameters:
  • y_range (Tuple[float, float]) – The desired y-axis range.

  • padding (Tuple[float, float] | None, optional) – The padding to be applied to the x-axis range, in decimal percent. Defaults to None.

_update_from_config(config) None#

Updates the plot configuration based on the provided config object.

Parameters:

config (Config) – The configuration object containing the plot settings.

Returns:

None

_verify_column(colname: str | int, name: str) str#

fetch data from column name

Parameters:
  • colname (str | int) – column name of data to fetch or the index of the column to fetch

  • name (str) – name of the column e.g. x, y, z for error message

Returns:

pandas series or None

Return type:

pd.Series

Raises:
  • ValueError – if colname is None

  • KeyError – if colname is not in data

  • ValueError – if colname is not numeric

property current_color: str#

Get the current color for the plot.

Returns:

The current color.

Return type:

str

property current_type: str#

Get the current type for the plot.

Returns:

The current type.

Return type:

str

abstractmethod generate(tooltips, custom_hover_data, fixed_tooltip_for_trace)#

Generate the plot

Parameters:
  • tooltips – Tooltip specifications for the plot. For Plotly, this is a hovertemplate string. For Bokeh, this is a list of (label, field) tuples. Ignored by Matplotlib (no interactive tooltips).

  • custom_hover_data – Additional data array for hover tooltips. Used by Plotly to populate customdata fields referenced in the hovertemplate. Ignored by Bokeh and Matplotlib backends.

  • fixed_tooltip_for_trace (bool) – Whether to use fixed tooltip data per trace (True) or varying tooltip data that matches each point in the trace (False). This parameter is only used by the Plotly backend.

property known_columns: List[str]#

List of known columns in the data, if there are duplicates outside of these columns they will be grouped in aggregation if specified

load_config(**kwargs)#

Load the configuration settings for the plot.

abstractmethod plot() None#

Create the plot

update_config() None#

Update the _config object based on the provided kwargs. This means that the _config will store an accurate representation of the parameters