Histogram - Trident Chemwidgets - Docs v0.1

Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Histogram

class trident_chemwidgets.Histogram(**kwargs: Any)

  Bases: `DOMWidget`

  Plot an interactive histogram based on the distribution of the given data and the selected variable.

  The histogram 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) – DataFrame used to generate the histogram.

    - 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 histogram.

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

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

  Notes

  Valid date format strings for the x_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)
      >>> histogram = tcw.Histogram(data=dataset, smiles='smiles', x='tpsa')
      >>> histogram

  property selection

    Current selection of molecules made by the user.

## Interaction features

### 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.

### 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 Histogram widget.