TidierOrg / TidierPlots.jl

Tidier data visualization in Julia, modeled after the ggplot2 R package.
MIT License
196 stars 7 forks source link

Macro @aes giving struct error in version 0.6.6 #85

Closed cnrrobertson closed 2 months ago

cnrrobertson commented 2 months ago

Recently updated Tidier where TidierPlots was updated from 0.5.5 to 0.6.6 and @aes is no longer working. Here's a simple example:

 ggplot(penguins) +
             @aes(x=species, y=bill_depth_mm) +
             geom_point()

with error:

ERROR: type Aesthetics has no field aes
Stacktrace:
 [1] getproperty
   @ ./Base.jl:37 [inlined]
 [2] (::TidierPlots.var"#4#15")(i::TidierPlots.Aesthetics)
   @ TidierPlots ./none:0
 [3] iterate
   @ ./generator.jl:47 [inlined]
 [4] grow_to!(dest::Vector{Union{}}, itr::Base.Generator{Base.Iterators.Filter{TidierPlots.var"#5#16", Tuple{TidierPlots.Aesthetics, TidierPlots.Geom}}, TidierPlots.var"#4#15"})
   @ Base ./array.jl:907
 [5] collect(itr::Base.Generator{Base.Iterators.Filter{TidierPlots.var"#5#16", Tuple{TidierPlots.Aesthetics, TidierPlots.Geom}}, TidierPlots.var"#4#15"})
   @ Base ./array.jl:831
 [6] +(::TidierPlots.GGPlot, ::TidierPlots.Aesthetics, ::TidierPlots.Geom)
   @ TidierPlots ~/.julia/packages/TidierPlots/CA1NI/src/addplots.jl:19
adknudson commented 2 months ago

Did you mean to have @aes outside of the call to ggplot or geom_point? Both of the following work for me on v0.6.6

ggplot(penguins) + 
    geom_point(@aes(x=species, y=bill_depth_mm))

ggplot(penguins, @aes(x=species, y=bill_depth_mm)) + 
    geom_point()
[a93c6f00] DataFrames v1.6.1
[8b842266] PalmerPenguins v0.1.4
[337ecbd1] TidierPlots v0.6.6
kdpsingh commented 2 months ago

aes() outside of ggplot is valid in R's ggplot2, so we should look at supporting it in TidierPlots. I've noticed that this style is becoming popular, and it's essentially equivalent to writing ggplot(aes(...)) but is a bit cleaner.

rdboyes commented 2 months ago

This should be easy to add support for, I just didn't know people used this syntax

rdboyes commented 2 months ago

This works again in the dev version!

ggplot(penguins) +
    aes(x=:species, y=:bill_depth_mm, color=:species) +
    geom_boxplot()

image