Open cnrrobertson opened 5 months ago
Can you elaborate on the first point? I think legends already work with categorical variables, e.g.
ggplot(penguins, @aes(x=bill_length_mm,y=bill_depth_mm,color=island)) + geom_point()
You're right! I didn't realize. But I think I've stumbled on a bug - it doesn't work when the DataFrame column for color
is a CategoricalVector
(apparently most/all? datasets from RDatasets.jl
have categorical columns stored in that format). But I think this an upstream issue in Makie:
ERROR: MethodError: no method matching to_color(::CategoricalValue{String, UInt8})
Closest candidates are:
to_color(::Makie.Palette)
@ Makie ~/.julia/packages/Makie/iRM0c/src/conversions.jl:845
to_color(::Symbol)
@ Makie ~/.julia/packages/Makie/iRM0c/src/conversions.jl:854
to_color(::Makie.Scene, ::Any, ::Makie.Cycled)
@ Makie ~/.julia/packages/Makie/iRM0c/src/makielayout/blocks/axis.jl:695
...
You can recreate with
using CategoricalArrays
penguins.island = categorical(penguins.island)
ggplot(penguins, @aes(x=bill_length_mm, y=bill_depth_mm, size=island)) + geom_point()
Alternatively, we could try to convert those columns to strings when plotting?
It's strange - I actually convert the Strings to CategoricalVectors under the hood already. Should be an easy fix I think, I'm sure I'm just missing a check somewhere
This is fixed in 0.8.0! Multiple legends are still a work in progress though
Describe how it works in R's
ggplot2
ggplot(diamonds, aes(x=x,y=y,color=color)) + geom_point()
ggplot(diamonds, @aes(x=Depth, y=Price)) + geom_point(@aes(color=Carat)) + geom_point(@aes(color=Table))
size
andcolor
), Example:ggplot(diamonds, aes(x=x,y=y,color=color, size=carat)) + geom_point()