Plotly.toImage Background Color

When exporting a static image with Plotly.toImage, I see there are options for size and format, but I’m wondering if there are options for changing the background color of the plot. Currently, I’m plotting them with a black background. I’d like to export them with a white background so I can add them to a printable PDF report (black background = no fun with a printer).

If this isn’t a current option, would you mind pointing me in a direction where I might be able to play with this on my own and make it happen?

I’m thinking I would add an options.plot_bgcolor on newLayout in cloneplot.js and then add plot_bgcolor as an option in the toImage function in toImage.js where clonedGd-fullLayout.style.plot_bgcolor = opts.plot_bgcolor.

Would love to hear if this is a good direction.

TIA!

  • Chiara

Here’s how: https://codepen.io/etpinard/pen/JpYaNX?editors=1010

1 Like

Thank you, @etienne! You all have thought of everything!

1 Like