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

Color by column #9

Open
jariji opened this issue Oct 15, 2024 · 4 comments
Open

Color by column #9

jariji opened this issue Oct 15, 2024 · 4 comments

Comments

@jariji
Copy link

jariji commented Oct 15, 2024

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
Copy link
Author

jariji commented Oct 15, 2024

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

@aplavin
Copy link
Member

aplavin commented Oct 16, 2024

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
Copy link
Member

aplavin commented Oct 21, 2024

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)".

@aplavin
Copy link
Member

aplavin commented Oct 23, 2024

Currently, calling scatter!(fplot) doesn't cycle color or other attributes – that's why you had to specify color=... manually in the calls in the first post.
This is a Makie bug I reported some time ago: MakieOrg/Makie.jl#4353.

While cycling doesn't work, it doesn't make much sense to implement stuff like scatter(FPlot(wide, (@o _.x), (@o _.y1 _.y2))). I want it to just reuse the regular Makie cycling functionality and not reimplement it myself.
But assuming that issue gets fixed at some point, such interface would be nice indeed!

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

2 participants