Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

offline.plot: allow specifying image_filename without image #906

Closed
jwhendy opened this issue Dec 29, 2017 · 2 comments
Closed

offline.plot: allow specifying image_filename without image #906

jwhendy opened this issue Dec 29, 2017 · 2 comments

Comments

@jwhendy
Copy link
Contributor

jwhendy commented Dec 29, 2017

I had some behavior I thought was odd when using plotly.offline.plot(). I tracked down my answer here:

            if image:
                if image not in __IMAGE_FORMATS:
                    raise ValueError('The image parameter must be one of the '
                                     'following: {}'.format(__IMAGE_FORMATS)
                                     )
                # if the check passes then download script is injected.
                # write the download script:
                script = get_image_download_script('plot')
                script = script.format(format=image,
                                       width=image_width,
                                       height=image_height,
                                       filename=image_filename,
                                       plot_id=plotdivid)
            else:
                script = ''

If I have numerous plots to embed, send, generate, etc. and I want to give them unique image filenames but I don't want them auto-downloading the generated plot every time I open them. Could one pass a filename so that when a file is downloaded you don't end up with newplot (n).png?

Originally I thought this would be a simple case where you set the filename associated with the little camera button, but now I realize that gets tricky as how would you know the type?

  • One way would be to allow image_filename without image='type' and default to png. This is the current functionality, but you're allowing the name to be customized when you click the camera button.

  • Another route could be to add an option like auto_dl or auto_save that is analogous to auto_open for plot(). Namely, just because I plot, don't open the webpage; just because I want to specify an image name, don't download it every time I open the page.

@cldougl
Copy link
Member

cldougl commented Jan 3, 2018

Hi there,

For your first option, the camera button functionality is associated with our core graphing library plotly.js changes to that would have to be made there rather in this repo so that functionality remains consistent across all of Plotly's APIs

Could you provide a use case for this second point? I'm not sure the auto_open analogy is appropriate here. When you choose to set auto_open to false, the plot is still generated and saved. It seems like in the case of setting auto_save=False there would be no resulting action so I'm not sure what benefit this option would provide.

@jwhendy
Copy link
Contributor Author

jwhendy commented Jan 3, 2018

The simple goal: I want to customize the image name, but I don't want an image to auto-download every time I open the file.

Currently, if I pass image, the Plotly.downloadImage script is injected, which means each time I open the .html, the plot image is downloaded. I don't want this; I just want it sitting there as custom-filename.png sitting and waiting for me to click. Sounds like it's not possible?

I think really what I want is image saving as a separate thing, which brings in #880 . Sounds like that's upcoming and I can have this: filename control and not have it integrated into the .html behavior.

@jwhendy jwhendy closed this as completed Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants