I have a plot with subplots that I export for PDF generation. That works great, but I also want images of the side plots on their own for this report. I hacked my way to this by plotting them separately in a hidden <div> and then exporting them, but I have 5 visible plots already and with those two, I end up having too many WebGL contexts on the page and even lose a context.
So, I think this is a long shot, but is there any way to make an image of a plot without actually plotting it in a <div>?
Plotly.toImage now accepts (I think this hasn’t made its way in our docs yet) a {data: [], layout: {}} object as first argument. This does create a hidden <div> (i.e. a <div> that we don’t attach to document.body) for you,
Plotly.toImage purges (equivalent to Plotly.purge) things like WebGL contexts on completion, so you shouldn’t see those too many WebGL context warnings.