Plots/GR: `savefig` adds transparency to my picture?

Hi, I have a curious phenomenon here which seemingly appeared from nowhere. I am doing a simple plot (using Plots) and saving it to a file ; but the saved version seems to be transparent.

The MWE is

using Plots
heatmap(rand(8,8))
p=plot!(aspect_ratio=:equal, colorbar=false, axis=([], false))
savefig(p, "test.png")

and here is what I get in my editor : left is my notebook showing the picture, right is the saved picture.

This issue occurs while plotting with default gr backend, but not with pythonplot.

For similar result, use keyword argument border=:none, which works fine with gr():

p = heatmap(rand(8,8))
plot!(aspect_ratio=:equal, colorbar=false, border=:none)

Hi Rafael (and sorry for this quite late answer !).
So there is no way to correctly save a coloured figure in the gr backend ???

1 Like

@jheinen any thoughts what might be happening here?

If you use the command that I recommended, then there is no issue with gr() backend. The saved figure looks good:

For me, p=plot!(aspect_ratio=:equal, colorbar=false, axis=([], false)) produces transparent plots both in the REPL and when saving the picture as a PNG. I’ll check it ASAP.

1 Like

Juste checked again and border=:none solves my question, thanks. However this behaviour is quite strange !

Sorry for the late reply. This MR should fix the problem.

1 Like