Scatter#

class trident_chemwidgets.Scatter(**kwargs: Any)[source]#

Bases: DOMWidget

Plot an interactive scatter plot based on the given data and the selected variables to generate the axis.

The scatter plot will be displayed to the left of the cell output, with a molecule gallery displayed to the right. The molecule gallery can show the structures present in the currently-selected subset of the data.

Parameters
  • data (pd.DataFrame) – Data used to generate the scatter plot.

  • smiles (str) – Name of the column that contains the SMILES string of each molecule.

  • x (str) – Name of the column used to generate the x-axis of the scatter plot.

  • y (str) – Name of the column used to generate the y-axis of the scatter plot.

  • hue (str) – Name of the column used to color the points of the scatter plot.

  • x_label (str) – Label for the x-axis of the histogram, defaults to the value of x if not provided.

  • y_label (str) – Label for the y-axis of the histogram, defaults to the value of y if not provided.

  • hue_label (str) – Label for the point colors of the histogram, defaults to the value of hue if not provided.

  • x_date_format (str) – Date format string to display datetime values on the x axis.

  • y_date_format (str) – Date format string to display datetime values on the y axis.

Notes

Valid date format strings for the x_date_format and y_date_format arguments can be found here: https://github.com/d3/d3-time-format#locale_format. For example, a common date format string might be ‘%Y-%m-%d’ to display the 4-digit year, 2-digit month, and 2-digit day (i.e. 2021-12-25).

Examples

>>> import trident_chemwidgets as tcw
>>> import pandas as pd
>>> dataset = pd.read_csv(PATH)
>>> scatter = tcw.Scatter(data=dataset, smiles='smiles', x='mwt', y='logp')
>>> scatter
property selection#

Current selection of molecules made by the user.

Interaction features#

Scatter interface

Selecting data#

Once the widget renders, click and drag within the plot area to select a subset of the data. The selected data points will change color to teal and have a dark blue outline.

Displaying selected structures#

Once a subset of the data has been selected, you can then press the SHOW STRUCTURES button to display a gallery of the selected structures in the space to the right of the plot.

Saving selected subset to selection property#

You can save the current selection of data by clicking SAVE SELECTION. This action will make current subset of the data available using the selection property of the widget. To clear the current selection, click anywhere in the plot area. Note that if you clicked SAVE SELECTION, the reference to those data points will be saved until it is overwritten by the SAVE SELECTION button being clicked for a new selection.

Example#

See Using the Scatter widget.