Black Lives Matter. Please consider donating to Black Girls Code today.

Export Image without Plotting

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>?


Chiara might give you ideas.

A couple things to note:

  • 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.

I hope this helps.

1 Like

:100: :100: :100::100: :100: :100:

Seriously thought that I was SOL on this one. Haha!

Let’s see how many times I can say thank you in a year.

Thank you! (I think this makes 3)


1 Like