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

Add from_continuous helper function for categorical use of continuous colormaps #541

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

jkrumbiegel
Copy link
Member

Allows to sample continuous colormaps evenly to use them as categorical palettes without having to specify how many categories there are:

using AlgebraOfGraphics
using CairoMakie

spec = data((; x = 1:10, y = 1:10, z = 'A':'J')) *
    mapping(:x, :y, color = :z) *
    visual(BarPlot)

f = Figure()
fg1 = draw!(f[1, 1], spec, scales(Color = (; palette = [:red, :blue])))
legend!(f[1, 2], fg1)
fg2 = draw!(f[1, 3], spec, scales(Color = (; palette = from_continuous([:red, :blue]))))
legend!(f[1, 4], fg2)
f
image

@jkrumbiegel jkrumbiegel merged commit e8d1a5c into master Aug 27, 2024
5 checks passed
@jkrumbiegel jkrumbiegel deleted the jk/from_continuous branch August 27, 2024 08:55
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

Successfully merging this pull request may close these issues.

1 participant