JuliaAPlavin / MakieExtra.jl

MIT License
32 stars 2 forks source link

Color by column #9

Open jariji opened 5 days ago

jariji commented 5 days ago

Can we do this less verbosely?

let n = 50, wide = StructArray(id=1:n, x=rand(n), y1=rand(n), y2=rand(n))
    fig = Figure()
    ax = Axis(fig[1,1])
    colors = Makie.wong_colors()
    scatter!(ax, FPlot(wide, (@o _.x), (@o _.y1)); color=colors[1])
    scatter!(ax, FPlot(wide, (@o _.x), (@o _.y2)); color=colors[2])
    fig
end

image

jariji commented 5 days ago

Maybe axislegend(ax) could figure out good labels from the y expressions too.

aplavin commented 4 days ago

I sometimes do similar stuff indeed, writing it as

fplt = FPlot(wide, (@o _.x))
scatter!(@insert fplt[2] = @o _.y1)
scatter!(@insert fplt[2] = @o _.y2)

or (more commonly)

fplt = FPlot(data, (@o _.x))
for i in 1:5
    scatter!(@insert fplt[2] = @o _.y[i])  # y in each row is a 5-element array
end

Not sure how a better interface would look like...

aplavin commented 4 hours ago

Oh, that's what comes to mind:

FPlot(wide, (@o _.x), (@o _.y1 _.y2))  # for several independent columns
FPlot(data, (@o _.x), (@o _.y[∗]))  # for array/tuple/... elements

The full semantics need to be carefully thought of, as this would be the first departure from "one FPlot plot call = one regular Makie plot call (just with cleverely forwarded args)".