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

ggMarginal can’t handle Date axes #45

Open
flying-sheep opened this issue Mar 24, 2017 · 2 comments
Open

ggMarginal can’t handle Date axes #45

flying-sheep opened this issue Mar 24, 2017 · 2 comments

Comments

@flying-sheep
Copy link

flying-sheep commented Mar 24, 2017

library(ggExtra)
data(airquality)
airquality$Date <- with(airquality, as.Date(sprintf('1973-%02d-%02d', Month, Day)))

p <- ggplot(airquality, aes(Date, Temp)) + geom_point()
print(ggMarginal(data = airquality, x = 'Date', y = 'Temp'))  # works
print(ggMarginal(p, airquality, 'Date'))                      # doesn’t

the second one throws:

Error: Invalid input: date_trans works with objects of class Date only
Traceback:

1. print(ggMarginal(p, airquality, "Date"))
2. ggMarginal(p, airquality, "Date")
3. ggplot2::ggplot_build(top)
4. lapply(data, scales_transform_df, scales = scales)
5. FUN(X[[i]], ...)
6. unlist(lapply(scales$scales, function(s) s$transform_df(df = df)), 
 .     recursive = FALSE)
7. lapply(scales$scales, function(s) s$transform_df(df = df))
8. FUN(X[[i]], ...)
9. s$transform_df(df = df)
10. f(..., self = self)
11. lapply(df[aesthetics], self$transform)
12. FUN(X[[i]], ...)
13. f(..., self = self)
14. self$trans$transform(x)
15. stop("Invalid input: date_trans works with objects of class Date only", 
  .     call. = FALSE)
@daattali
Copy link
Owner

Thank you for the report. ggExtra is currently undergoing major revisions and hopefully this will be solved in the next version

@crew102
Copy link
Contributor

crew102 commented May 15, 2017

I looked into this and it's only easy to fix it for the top marginal plot. I believe you would have to go deep into the internals of ggplot2 to get it working for both top and right marginal plots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants