how get fiure saved from Plotlyfig on PyCharm

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin

Hi Nitin.

I tend to just generally have trouble running notebooks in Pycharm.

Do you still get the issue if running on a Jupyter notebook? If so then it is a problem with PlotlyFig rather than Pycharm and we can look into it further.

Thanks,

Alex

···

On Wednesday, February 20, 2019 at 1:56:54 PM UTC-8, Nitin Kumar wrote:

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin

**Meaning running on a Jupyter server in a web browser, for example.

···

On Thursday, February 21, 2019 at 5:50:58 PM UTC-8, [email protected] wrote:

Hi Nitin.

I tend to just generally have trouble running notebooks in Pycharm.

Do you still get the issue if running on a Jupyter notebook? If so then it is a problem with PlotlyFig rather than Pycharm and we can look into it further.

Thanks,

Alex

On Wednesday, February 20, 2019 at 1:56:54 PM UTC-8, Nitin Kumar wrote:

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin

Hi Alex, This is working on Jupyter notebook.

Nitin

···

On Wednesday, February 20, 2019 at 2:56:54 PM UTC-7, Nitin Kumar wrote:

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin

Ah ok. If it is working on a regular Jupyter notebook, I am not sure how to fix it in pycharm (perhaps worth opening up a ticket on Plotly though).

If you like running notebooks in Pycharm rather than web browser, one thing you could do is change the mode to “offline” and try saving plots to disk. Your plot won’t appear in pycharm, but it will at least save to disk (rather than spew out text in a cell).

Thanks,

Alex

···

On Thursday, February 21, 2019 at 6:22:24 PM UTC-8, Nitin Kumar wrote:

Hi Alex, This is working on Jupyter notebook.

Nitin

On Wednesday, February 20, 2019 at 2:56:54 PM UTC-7, Nitin Kumar wrote:

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin

Thanks Alex! Jupyter notebook works quite badly on PyCharm so I will use the web browser for it.

···

On Wednesday, February 20, 2019 at 2:56:54 PM UTC-7, Nitin Kumar wrote:

Hi,

I am running the “https://github.com/hackingmaterials/matminer_examples/blob/master/notebooks/machine-learning/intro_predicting_bulk_modulus.ipynb” example on PyCharm. When I run the 16th Input i.e.:

from matminer.figrecipes.plot import PlotlyFig

from sklearn.model_selection import cross_val_predict

pf = PlotlyFig(x_title=‘DFT (MP) bulk modulus (GPa)’,

y_title=‘Predicted bulk modulus (GPa)’,

title=‘Linear regression’,

mode=‘notebook’,

filename=“lr_regression.html”)

pf.xy(xy_pairs=[(y, cross_val_predict(lr, X, y, cv=crossvalidation)), ([0, 400], [0, 400])],

labels=df[‘formula’],

modes=[‘markers’, ‘lines’],

lines=[{}, {‘color’: ‘black’, ‘dash’: ‘dash’}],

showlegends=False

)

on PyCharm, this doesn’t open/save any figure. It just prints out a bunch of lines. How can I save the output to a figure, png or any other format?

Thanks.

best,

Nitin