molplotly icon indicating copy to clipboard operation
molplotly copied to clipboard

Error when using with Plotly Subplots

Open matthewtoholland opened this issue 3 years ago • 3 comments

When trying to use molplotly to generate hover structures with a series of scatterplots generated using make_subplots (generated using different columns of a dataframe for the same RDKit molecule row), molplotly.add_molecules returns

ValueError: More than one plotly curve in figure - color_col and/or marker_col needs to be specified.

As these plots are generated using different columns, rather than faceting data in a single column based on values in another, there is no common color or marker column. Is there a way to generate molecular structures for these subplots?

matthewtoholland avatar Nov 03 '22 14:11 matthewtoholland

Hey, thanks for the question! Could you provide a toy example in code of what you'd like to plot? I'll try to have a look over the weekend :)

wjm41 avatar Nov 10 '22 23:11 wjm41

Sure, please find attached the test data. What I am looking for is a scatter plot faceted by the 'variable' column (so should be three plots), where the structures are revealed on hovering. I have included a code snippet below!

data = pd.read_csv('test_data.csv')
plot = px.scatter(data, x='value', y='Assay', facet_col='variable', hover_name='variable')
plot.update_xaxes(range=[1.0, 0.6])
plot.update_yaxes(range=[2.5, 0])

test_data.csv

Thank you!

matthewtoholland avatar Nov 14 '22 14:11 matthewtoholland

Hey, sorry for the delay - I've updated the package and it should be able to handle data faceting now. Could you install the latest version with pip install molplotly==1.1.5 and see if that works for you? :D

I haven't tested make_subplots yet but if it's just using facet_col in scatter it should work. I've included your example data at the end of examples/simple_usage_and_formatting.ipynb to showcase it working!

wjm41 avatar Nov 24 '22 15:11 wjm41