Here’s my example:
import pandas as pd
import plotly
import plotly.graph_objs as go
df = pd.DataFrame(
{'fruits': ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries'],
'counts': [5, 3, 4, 2, 4, 6] })
data = [go.Bar(x=df['fruits'],
y=df['counts'])]
fname = 'fruit-plot'
plotly.offline.plot(data, filename='{}.html'.format(fname), auto_open=False,
image_filename=fname, image='png')
This gives me a html file (without auto-opening it). When I do open it, the file fruit-plot.png
is automatically downloaded to ~/Downloads
(using chromium
). I attempted not to specify image='png'
as I don’t want to auto-download the file, but I do want to specify it’s name.
plotly.offline.plot(data, filename='{}.html'.format(fname), auto_open=False,
image_filename=fname)
Now when I click the camera, I get the file newplot.png
.
The docs don’t really explain how one might change the default filename while avoiding the auto-download behavior. These are the only relevant options I see:
image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
the format of the image to be downloaded, if we choose to download an
image. This parameter has a default value of None indicating that no
image should be downloaded. Please note: for higher resolution images
and more export options, consider making requests to our image servers.
Type: `help(py.image)` for more details.
image_filename (default='plot_image') -- Sets the name of the file your
image will be saved to. The extension should not be included.
If these two need to be used in conjunction (image_filename
sort of “requires” image='type'
), could the docs be updated to this effect?