Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plots saved to file loose colour #1599

Open
evan-wehi opened this issue Oct 16, 2022 · 3 comments
Open

Plots saved to file loose colour #1599

evan-wehi opened this issue Oct 16, 2022 · 3 comments

Comments

@evan-wehi
Copy link

I’m saving Gadfly plots as PNG, SVG or JPG but the colour is stripped from them, making them useless. The problem occurs on Mac silicon and linux and the current stable releases of Julia and packages.

Here is the plot in the edit plot window. Interestingly, if I save from the plot window it is fine.
image

Here is the plot after writing to a file:
image

If I save a plot on its own it's fine, it's the stacked plots that are the problem.

Here is a code to reproduce:

using DataFrames, Gadfly, Cairo, Random

rd(m) = m .+ 100*randn(100) 
f1 = DataFrame(BCL2=rd(500), BCLxL=rd(500), MCL1=rd(500), NOXA=rd(500), dose="0mg")
f2 = DataFrame(BCL2=rd(700), BCLxL=rd(700), MCL1=rd(700), NOXA=rd(700), dose="200mg")
f4p = vcat(f1, f2)

layers = Plot[]
for protein in [:MCL1, :NOXA, :BCLxL, :BCL2]
  l = plot(f4p, x=protein, color=:dose, Geom.histogram)
  fn = "$(string(protein)).png"
  push!(layers, l)
  l |> PNG(fn)
end
layers = reshape(layers, 2, 2)
h = gridstack(layers)
display(h)
fn = "broken.png"
h |> PNG(fn)
@Mattriks
Copy link
Member

Try putting the h |> PNG(fn) before the display(h) line?

@evan-wehi
Copy link
Author

Nice catch! If I swap those lines, the file is fine but the plot in the editor window is corrupted.

@bjarthur
Copy link
Member

so display mutates its input? is that expected?? is there a fix???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants