This might be a simple question but I can’t find any documentation on this. I’m trying to run my python script and am saving my plots offline with
This is all good and the plot saves, but whenever I run the script I get an error on my command line:
xdg-open: no method available for opening 'C:/sampleplot.html'
Am I saving it in the wrong format? Don’t get why it’s trying to open the plot, I just want it to be saved. Is there a savefig function similar to matplotlib? Thanks for the help
py.plot(fig, filename=name.html') sends the plot to Plotly cloud, and doesn’t save the file on your system.
If you are working offline, then
plotly.offline.plot(fig, filename='name.html') saves the html file on your machine and you can open it in a browser, but usually it opens instantly.
yeah I’m using polty.offline.plot. It saves the html file to my machine, but whenever I run the script I think it’s trying to open the file in my command terminal and I get an xdg-open error. Is there any way to stop this from being outputted?
py file from Jupyter notebook or a Python IDE, not from terminal.
But I just want to save the HTML file, not open up the chart once it’s run- does that make sense? Is there no way to do this? I thought there was an entire thing of functionality built into plotly offline
plotly.offline.plot(fig, filename = 'filename.html', auto_open=False)
Brilliant! Was wondering why do my exports freeze on the Linux console, that’s why
That does not work. There is no file created.
As of version 3.8, the best way to save a figure to html is using the
plotly.io.write_html function. See the docstring for more info.
As of version 4.0, the
write_html() function is available on
go.Figure objects as well, so you can do
fig.write_html("path/to/file.html") directly now too.
That was what I needed. Thank you.
Here is the canonical documentation page for this feature:
I use plotly.io.write_html, but I have this error.
this is my code
import plotly as py
import pandas as pd
import numpy as np
from datetime import datetime
from datetime import time as dt_tm
from datetime import date as dt_date
# import plotly.plotly as py
import plotly.tools as plotly_tools
import plotly.graph_objs as go
os.environ['MPLCONFIGDIR'] = tempfile.mkdtemp()
# from matplotlib.finance import quotes_historical_yahoo
import matplotlib.pyplot as plt
from scipy.stats import gaussian_kde