Chemical explorer
Charts
Scientific
Sliders and a plotly lasso jointly filter the same mols2grid grid in place, with a click-to-inspect detail card and a selection-to-SDF download.
257 molecules from mols2grid’s bundled solubility dataset, with molecular weight and LogP computed via RDKit. Two molecular-weight/LogP sliders and a lasso-able plotly scatter plot both narrow the same mols2grid grid – combined with AND – entirely through grid.grid.filter(), so the grid is never rebuilt and the checkbox selection and scroll position survive every adjustment.


Run it
git clone --depth 1 https://github.com/posit-dev/py-shinywidgets
cd py-shinywidgets/website/gallery/showcases/chemical-explorer
uv run shiny run app.pySource: app.py · Open in Shinylive
Try this
- Drag either slider: the grid’s visible molecules narrow immediately.
- Lasso- or box-select points on the MW-vs-LogP scatter plot: the grid narrows to just those molecules, intersected with whatever the sliders already allow.
- Click a molecule’s image in the grid: a detail card on the right redraws it with RDKit and shows its MW/LogP/LogS.
- Check a few molecules’ boxes, then Download as SDF: downloads exactly the checked molecules as a standard SDF file.
Accessors demonstrated
grid.clicked()– the full row (as a dict) of the most recently clicked molecule, used to drive both the RDKit depiction and the descriptor text.Noneuntil a first click.grid.selected()– the dict of currently checkbox-selected molecules (by mols2grid’s own index), read both for the live count and for the SDF export.scatter.selected()/scatter.selected_rows()– the plotly lasso’s selection, converted to a boolean mask over the same dataframe and combined with the slider mask before callinggrid.grid.filter().