Skip to content

Commit dbe76ea

Browse files
author
wjm41
authored
Merge pull request #10 from wjm41/docs/save
Docs/save
2 parents b5df13d + 8432e62 commit dbe76ea

File tree

11 files changed

+5346
-27907
lines changed

11 files changed

+5346
-27907
lines changed

README.md

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
![Beautiful :)](https://raw.githubusercontent.com/wjm41/molplotly/main/images/pca.gif)
1010
![Beautiful :)](https://raw.githubusercontent.com/wjm41/molplotly/main/images/multiple_smiles.gif)
1111

12-
➡️  A readable walkthrough of how to use the package together with some useful examples can be found in [this blog post](https://www.wmccorkindale.com/post/introducing-molplotly) while a runnable notebook can be found in `example.ipynb` :)
12+
➡️  A readable walkthrough of how to use the package together with some useful examples can be found in [this blog post](https://www.wmccorkindale.com/post/introducing-molplotly) while a runnable notebook can be found in `examples/example.ipynb` :)
1313

1414
## ⬇️ Installation
1515

@@ -27,7 +27,8 @@ import plotly.express as px
2727
import molplotly
2828

2929
# load a DataFrame with smiles
30-
df_esol = pd.read_csv('esol.csv')
30+
df_esol = pd.read_csv(
31+
'https://raw.githubusercontent.com/deepchem/deepchem/master/datasets/delaney-processed.csv')
3132
df_esol['y_pred'] = df_esol['ESOL predicted log solubility in mols per litre']
3233
df_esol['y_true'] = df_esol['measured log solubility in mols per litre']
3334

@@ -45,54 +46,65 @@ app = molplotly.add_molecules(fig=fig,
4546
app.run_server(mode='inline', port=8011, height=1000)
4647
```
4748

48-
#### Input parameters
49+
### Input parameters
4950

5051
- `fig` : plotly.graph_objects.Figure object\
51-
a plotly figure object containing datapoints plotted from df
52+
a plotly figure object containing datapoints plotted from `df`.
5253

5354
- `df` : pandas.DataFrame object\
54-
a pandas dataframe that contains the data plotted in fig
55+
a pandas dataframe that contains the data plotted in `fig`.
5556
- `smiles_col` : str, optional\
56-
name of the column in df containing the smiles plotted in fig (default 'SMILES')
57+
name of the column in df containing the smiles plotted in `fig` (default 'SMILES').
5758
- `show_img` : bool, optional\
58-
whether or not to generate the molecule image in the dash app (default True)
59+
whether or not to generate the molecule image in the dash app (default True).
60+
- `svg_size` : float, optional
61+
the size in pixels of the molecule drawing (default 200).
62+
- `alpha` : float, optional\
63+
the transparency of the hoverbox, 0 for full transparency 1 for full opaqueness (default 0.7).
64+
- `mol_alpha` : float, optional\
65+
the transparency of the SVG molecule image, 0 for full transparency 1 for full opaqueness (default 0.7).
5966
- `title_col` : str, optional\
60-
name of the column in df to be used as the title entry in the hover box (default None)
67+
name of the column in df to be used as the title entry in the hover box (default None).
6168
- `show_coords` : bool, optional\
62-
whether or not to show the coordinates of the data point in the hover box (default True)
69+
whether or not to show the coordinates of the data point in the hover box (default True).
6370
- `caption_cols` : list, optional\
64-
list of column names in df to be included in the hover box (default None)
71+
list of column names in df to be included in the hover box (default None).
6572
- `caption_transform` : dict, optional\
66-
Functions applied to specific items in all cells. The dict must follow a key: function structure where the key must correspond to one of the columns in subset or tooltip. (default {})
73+
Functions applied to captions for formatting. The dict must follow a key: function structure where the key must correspond to one of the columns in subset or tooltip (default {}).
6774
- `color_col` : str, optional\
68-
name of the column in df that is used to color the datapoints in df - necessary when there is discrete conditional coloring (default None)
75+
name of the column in df that is used to color the datapoints in df - necessary when there is discrete conditional coloring (default None).
76+
- `marker_col` : str, optional\
77+
name of the column in df that is used to determine the marker shape of the datapoints in df (default None).
6978
- `wrap` : bool, optional\
70-
whether or not to wrap the title text to multiple lines if the length of the text is too long (default True)
79+
whether or not to wrap the title text to multiple lines if the length of the text is too long (default True).
7180
- `wraplen` : int, optional\
72-
the threshold length of the title text before wrapping begins - adjust when changing the width of the hover box (default 20)
81+
the threshold length of the title text before wrapping begins - adjust when changing the width of the hover box (default 20).
7382
- `width` : int, optional\
74-
the width in pixels of the hover box (default 150)
83+
the width in pixels of the hover box (default 150).
7584
- `fontfamily` : str, optional\
76-
the font family used in the hover box (default 'Arial')
85+
the font family used in the hover box (default 'Arial').
7786
- `fontsize` : int, optional\
78-
the font size used in the hover box - the font of the title line is fontsize+2 (default 12)
87+
the font size used in the hover box - the font of the title line is fontsize+2 (default 12).
7988

8089
#### Output parameters
8190

8291
by default a JupyterDash `app` is returned which can be run inline in a jupyter notebook or deployed on a server via `app.run_server()`
8392

8493
- The recommended `height` of the app is `50+(height of the plotly figure)`.
85-
- For the `port` of the app, make sure you don't pick the same `port` as another `molplotly` plot otherwise the tooltips will clash with each other!
94+
- For the `port` of the app, make sure you don't pick the same `port` as another `molplotly` plot otherwise the tooltips will clash with each other. Also, apparently on windows port numbers below `8700` are used by other processes so for safety processes keep to numbers above that.
8695

8796
## 💻   Can I run this in colab?
8897

89-
JupyterDash is supposed to have support for Google Colab but at some point that seems to have broken... Keep an eye on the raised issue [here](https://github.com/plotly/jupyter-dash/issues/10)!
98+
JupyterDash is supposed to have support for Google Colab but at some point that seems to have broken.. Keep an eye on the raised issue [here](https://github.com/plotly/jupyter-dash/issues/10)!
99+
Update (1st March 2022): The plots seem to be running again but the hoverboxes are not showing so I don't think it has been fully fixed - I will keep an eye on it in the meantime.
90100

91101
## 💾   Can I save these plots?
92102

103+
An issue/feature request for this has already been raised [here](https://github.com/wjm41/molplotly/issues/4).
104+
93105
`moltplotly` works using a Dash app which is non-trivial to export because server side javascript is needed in addition to HTML/CSS styling ([as detailed here](https://stackoverflow.com/questions/60097577/how-to-export-a-plotly-dashboard-app-into-a-html-standalone-file-to-share-with-t))
94106

95-
Until I find a way to get around that, the best alternative is exporting the plotly figure without molecules showing :( as detailed in this [page](https://plotly.com/python/interactive-html-export/). If you want to use it in a presentation I'd suggest keeping the figure open in a browser and changing windows to it during your talk!
107+
Until I find a way to get around that, the best alternative is to either host the plot on an app/server, exporting the plotly figure without molecules showing :( as detailed in this [page](https://plotly.com/python/interactive-html-export/). If you want to use it in a presentation I'd suggest keeping the figure open in a browser and changing windows to it during your talk!
96108

97109
## 🛑  Warning about memory size
98110

0 commit comments

Comments
 (0)