Page 1 of 1

Question about transparent backgrounds in PNG image exports

Posted: Wed Mar 25, 2026 12:07 am
by NourEdinDarwish
Hi,

I am currently developing a new module in jamovi, and I've run into a dilemma regarding plot backgrounds and exporting images.

I've noticed that when a plot is exported as a PNG image, the background is transparent by default. While this transparent background behavior works beautifully within the jamovi results output, specifically because it allows the plot to correctly "grey out" when a new analysis is added below it, it creates issues when the image is saved externally.

If I manually force a white background in my R code (e.g., using

Code: Select all

theme(plot.background = element_rect(fill = "white"))
), the exported PNG looks great in external image viewers. However, doing this breaks the native jamovi UI behavior; the plot no longer "greys out" when it becomes an older analysis, which makes it look inconsistent compared to other modules.

On the other hand, if I leave it transparent so it behaves correctly in the jamovi UI, users who export the PNG and open it in a standard image viewer (many of which use dark mode or a black background by default) are left with a plot that is very hard to read and doesn't look good.

My questions are:
  • Is this transparent background for exported PNGs the strictly intended behavior, and is this what users generally expect when they save a plot?
  • Is there a recommended way to force a solid white background only when the user saves/exports the image, while keeping it transparent in the jamovi results viewer so the "grey out" effect still works? Or is there a way to let the user control the export background?
Thanks in advance!

Re: Question about transparent backgrounds in PNG image exports

Posted: Wed Mar 25, 2026 12:57 am
by jonathon
this is a good issue to raise. i think we should change the export behaviour so that produces an image with a white background.

let me take a look.

jonathon