TidierOrg / TidierPlots.jl

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

Facetting not working! #41

Closed aelmokadem closed 10 months ago

aelmokadem commented 10 months ago

Hi,

Want to start by saying this is a wonderful ecosystem for Julia.

I am having an issue using facetting with TidierPlots.jl. The code below gives an error

using TidierPlots

df = DataFrame(x = [1,2,3,4,5,6], y = [5,6,7,8,9,0], z=["a","a","b","b","c","c"])

@ggplot(data=df, aes(x=x,y=y)) + @geom_point() + @facet_wrap(z)

The error:

ERROR: LoadError: UndefVarError: `@facet_wrap` not defined
in expression starting at /data/cytomx/svn-proj-CTM0701C/script/test.jl:5

What am I missing here?

rdboyes commented 10 months ago

I'm just cleaning up the last bits of syntax still from the change I made away from macros!

ggplot(data=df, @es(x=x,y=y)) + geom_point() + facet_wrap(facets = :z) will do what you want, but I still need to update facet_wrap to take strings instead of Julia-style symbols

rdboyes commented 10 months ago

or - as well as Julia-style symbols, I guess

aelmokadem commented 10 months ago

Thank you @rdboyes for the fast reply. This line doesn't seem to work still! Just facet_wrap is not recognized?!

@ggplot(data=df, @aes(x=x,y=y)) + @geom_point() + facet_wrap(facets = :z)
ERROR: UndefVarError: `facet_wrap` not defined
rdboyes commented 10 months ago

ggplot and geom_point are both not macros - they should not have the @ before them

aelmokadem commented 10 months ago

Ok so I tried these:

julia> ggplot(data=df, @aes(x=x,y=y)) + geom_point() + facet_wrap(facets = :z)
ERROR: LoadError: UndefVarError: `@aes` not defined
julia> ggplot(data=df, aes(x=x,y=y)) + geom_point() + facet_wrap(facets = :z)
ERROR: UndefVarError: `x` not defined

so looks like I am still missing something!!

rdboyes commented 10 months ago

do you have the latest version installed? all of the functions that it says you are missing were added recently.

try

using Pkg
Pkg.add(url="https://github.com/TidierOrg/TidierPlots.jl")

and see if that resolves your issues

aelmokadem commented 10 months ago

I am using TidierPlots v0.1.0 !

rdboyes commented 10 months ago

That’s the problem then! The latest version is 0.5.2 and facetting wasn’t present in the 0.1.0 release. If you update to the latest version it should work as expected

aelmokadem commented 10 months ago

Oh OK. Will try that then. Thanks again @rdboyes

rdboyes commented 10 months ago

No problem - I'm guessing that you installed via the Tidier metapackage? I just pushed an update that will make that package install the correct version

aelmokadem commented 10 months ago

Yeah I think that's the issue that the update is restricted by the Tidier package. Once the push is in effect, I think it should be all good.

kdpsingh commented 10 months ago

@aelmokadem It's possible that you have an old version of Tidier.jl, which accidentally restricted upgrades to base packages. If you update Tidier.jl, you should then be able to update TidierPlots.jl. I'm planning to push out a new version of Tidier.jl soon that will install the latest versions of all the base packages.

kdpsingh commented 10 months ago

Thanks @rdboyes. I see you pushed the latest version. Thank you for doing that!

One thing to keep in mind is that specifying the full version number "0.5.2" won't allow for future updates to 0.7. But if you specify "0.5", then it will allow for future base package updates all the way up until 1. So I may tweak this in a future update with the intent of future-proofing Tidier.jl.

rdboyes commented 10 months ago

Ah - my mistake. Feel free to change it to "0.5" (or I can!)