Plotly.downloadImage seems to not always respect layout setting
See original GitHub issueAs mentioned here https://github.com/plotly/plotly.js/issues/2098#issuecomment-337622647 Plotly.downloadImage
should accept a layout object and it does normally.
When you define your layouts like I did in the following fiddle, it never respects a given layout object but rather chooses the layout object used for drawing the plot. (You can switch plotLayout and downLayout in the given fiddle around to test this.)
https://jsfiddle.net/7co1nf0v/
So how can I achieve keeping this namespace but also being able to pass a different layout for the downloadImage than for the plot drawing? Please point me towards any mistakes I may have made, I’m not totally firm with JavaScript yet. 😹
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Use plotly offline to save chart as image file
I made a script using selenium. It seems to work for webgl plots. import time from selenium import webdriver profile = webdriver.FirefoxProfile() profile....
Read more >Function reference in JavaScript - Plotly
The layout of the plot – non-data-related visual attributes such as the title, annotations etc – is described in an object usually called...
Read more >Plot sizing problems - plotly.js - Plotly Community Forum
When autosize comes into play, it seems to always pick a height of 450px ... With autosize not set, the width of the...
Read more >Python Figure Reference: layout - Plotly
Sets the title's horizontal alignment with respect to its x position. "left" means that the title starts at x, "right" means that the...
Read more >Static image export in Python - Plotly
Detailed examples of Static Image Export including changing color, size, log axes, and more in ... Plotly allows you to save static images...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(BTW, this kind of question is a better fit for community.plot.ly - github issues should be for bug reports or feature requests)
That’s the intended behavior. We could certainly do a better job of describing this in the docs… but you can’t put
data
orlayout
into the second argument, they need to be in the first argument (either directly, as you have it in your second fiddle, or already attached to a div).Plotly.downloadImage
is a wrapper aroundPlotly.toImage
, which is described more in the sourceNo matter what you do, we’re going to redraw the plot in the background when you ask for an image of it, since the image options can change how it is drawn. But the way you do it in your second fiddle is the correct way to do it, there are no unnecessary redraws there.
Hello @Braintelligence and thank you for reporting this!
From my understanding,
Plotly.downloadImage
will only honor alayout
object if it is provided in the first argument. In your first fiddle, thelayout
object is provided in the second argument which is why it doesn’t work. Your second fiddle does work because thelayout
is provided in the first argument!