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

theme_animint with theme_bw in ggplot2 #29

Closed
srvanderplas opened this issue Oct 25, 2014 · 8 comments
Closed

theme_animint with theme_bw in ggplot2 #29

srvanderplas opened this issue Oct 25, 2014 · 8 comments

Comments

@srvanderplas
Copy link
Collaborator

When using theme_bw() (or theme_grey, etc.), the theme_animint() statement has to come before any other theme set:

library(animint)
library(ggplot2)

df <- data.frame(x=rnorm(50), y=rnorm(50))
p1 <- ggplot() + 
   geom_point(data=df, aes(x=x, y=y)) + 
   theme_animint(width=500, height=500)

animint2dir(list(p=p1))

works fine, but

p2 <- ggplot() + 
  geom_point(data=df, aes(x=x, y=y)) + 
  theme_bw() + 
  theme_animint(width=500, height=500)

produces the error

> p2 <- ggplot() + 
+   geom_point(data=df, aes(x=x, y=y)) + 
+   theme_bw() + 
+   theme_animint(width=500, height=500)
Error in (function (el, elname)  : 
  "animint.width" is not a valid theme element name.

This error does not occur when theme_animint() is used before theme_bw():

p3 <- ggplot() + 
  geom_point(data=df, aes(x=x, y=y)) + 
  theme_animint(width=500, height=500) + 
  theme_bw()
@caijun
Copy link
Collaborator

caijun commented Mar 21, 2015

The same error produced when I source testthat.R

> servr::httd(port=4848, dir=file.path(getwd(), "testthat"), launch.browser=FALSE)
serving the directory /Users/tonytsai/Documents/R/package/animint/tests/testthat at http://localhost:4848
aesthetics : List of 1
 $ showSelected: symbol foo
.
animation : ...
1 character value : ....12
chunks : ......
coord : ....34
facet-coord : 56
facet lines : 

 Error in (function (el, elname)  : 
  "animint.width" is not a valid theme element name.

> sessionInfo()
R version 3.1.3 (2015-03-09)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.10.2 (Yosemite)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] plyr_1.8.1         maps_2.3-9         shiny_0.11.1       RSelenium_1.3.5    XML_3.98-1.1      
 [6] RJSONIO_1.3-0      RCurl_1.95-4.5     bitops_1.0-6       servr_0.1          animint_2015.01.27
[11] proto_0.3-10       ggplot2_1.0.1      testthat_0.9.1    

loaded via a namespace (and not attached):
 [1] caTools_1.17.1   colorspace_1.2-6 digest_0.6.8     grid_3.1.3       gtable_0.1.2     htmltools_0.2.6 
 [7] httpuv_1.3.2     labeling_0.3     MASS_7.3-39      mime_0.2         munsell_0.4.2    R6_2.0.1        
[13] Rcpp_0.11.5      reshape2_1.4.1   scales_0.2.4     stringr_0.6.2    tools_3.1.3      xtable_1.7-4

Last week I successfully ran all tests.

@caijun
Copy link
Collaborator

caijun commented Mar 21, 2015

I know what went wrong. Today I updated ggplot2. Re-installing animint and using the modified ggplot2 can avoid the error.

@cpsievert
Copy link
Collaborator

It seems that doing devtools::install_github(c("tdhock/ggplot2", "tdhock/animint")) does not fix this problem. @tdhock maybe we should add a note somewhere to always use theme_animint() before other theme() options?

@tdhock
Copy link
Owner

tdhock commented Mar 31, 2015

maybe put a message("put theme_animint before other theme options")?

@tdhock
Copy link
Owner

tdhock commented Mar 31, 2015

the real solution is to get it merged into ggplot2 ...

@tdhock
Copy link
Owner

tdhock commented Mar 31, 2015

I will add this as a test in tdhock/ggplot2 in case they ever merge it

@tdhock
Copy link
Owner

tdhock commented Mar 31, 2015

actually there was a bug in tdhock/ggplot2 which I just fixed and added tests for

@tdhock tdhock closed this as completed Mar 31, 2015
@srvanderplas
Copy link
Collaborator Author

I wouldn't count on that, but you could talk to Winston again just in
case...

On Tue, Mar 31, 2015 at 3:15 PM, Toby Dylan Hocking <
notifications@github.com> wrote:

the real solution is to get it merged into ggplot2 ...


Reply to this email directly or view it on GitHub
#29 (comment).

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

No branches or pull requests

4 participants