Fine-grained control over the print order in Gadfly?

I am creating a scatter chart that looks something like this:

using DataFrames using Gadfly using ColorBrewer using Distributions colors = palette("Set1", 4) df1 = DataFrame(rand(Normal(0, 0.5), 1000,2)) df1[:x3] = :a df2 = DataFrame(rand(Normal(-0.25, 0.25), 500,2)) df2[:x3] = :b df3 = DataFrame(rand(Normal(0.25, 0.25), 500,2)) df3[:x3] = :c df4 = DataFrame(rand(Normal(0, 0.25), 500,2)) df4[:x3] = :d df = vcat(df1, df2, df3, df4) plot(df, x=:x1, y=:x2, color=:x3, Geom.point, Scale.color_discrete_manual(colors..., levels=[:b, :c, :d, :a]), Theme(highlight_width=0pt)) 

I want the points built from front to back in this order [:d, :b, :c, :a] so that more points in :a at the back. So why should I specify the order as levels=[:b, :c, :d, :a] to get the desired result. What is the discrepancy here?

enter image description here

Also, interesting, it seems the order depends on what colors are used !? since trying different colors from ColorBrewer leads to different ordering results, which is probably a mistake. Relevant issue: https://github.com/dcjones/Gadfly.jl/issues/858

+7
julia-lang
source share
1 answer

FWIW, I gave up trying to fully control which layers overwrite layers when using Gadfly.

Perhaps this is even quite difficult to do, because sometimes my exact code, executed twice, creates two slightly different digits, in which the order in which the layer overwrites another layer changes apparently randomly. This happens, at least when I send the output to the postscript file via Gadfly.draw(PS(file, size...), p) , which I usually do.

Of course, this may improve in the future. I am currently using Gadfly 0.5.2 in Julia 0.5.0 under Windows 10, 64 bit.

+1
source share

All Articles