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?

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
julia-lang
tlnagy
source share