How to update theme_fullframe function in the wiki to new theme system?

295 views
Skip to first unread message

Trevor L Davis

unread,
Sep 21, 2012, 4:07:03 PM9/21/12
to ggp...@googlegroups.com
Any help would be very appreciated, I keep getting errors.  If I comment out the two lines setting axis.text.x and axis.text.y to element_blank() I get no error (but do get the undesired axis text). 

Thanks,

Trevor

> theme_fullframe <- function (base_size = 12){
+   theme(
+     axis.line = element_blank(),
+     axis.text.x = element_blank(),
+     axis.text.y = element_blank(),
+     axis.ticks = element_blank(),
+     axis.title.x = element_blank(),
+     axis.title.y = element_blank(),
+     axis.ticks.length = grid::unit(0, "lines"),
+     axis.ticks.margin = grid::unit(0, "lines"),
+     legend.position = "none",
+     panel.background = element_blank(),
+     panel.border = element_blank(),
+     panel.grid.major = element_blank(),
+     panel.grid.minor = element_blank(),
+     panel.margin = grid::unit(0, "lines"),
+     plot.background = element_blank(),
+     plot.margin = grid::unit(0*c(-1.5, -1.5, -1.5, -1.5), "lines")
+   )
+ }
> qplot(mpg, wt, data=mtcars) + theme_fullframe()
Error in grid.Call.graphics(L_setviewport, pvp, TRUE) :
  Non-finite location and/or size for viewport

Enter a frame number, or 0 to exit  

 1: print(list(data = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.
 2: print.ggplot(list(data = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16
 3: grid.draw(gtable)
 4: grid.draw.gtable(gtable)
 5: grid.draw(gt)
 6: grid.draw.gTree(gt)
 7: recordGraphics(drawGTree(x), list(x = x), getNamespace("grid"))
 8: drawGTree(x)
 9: grid.draw(x$children[[i]], recording = FALSE)
10: grid.draw.gTableChild(x$children[[i]], recording = FALSE)
11: NextMethod()
12: grid.draw.absoluteGrob(x$children[[i]], recording = FALSE)
13: grid:::drawGTree(x)
14: grid.draw(x$children[[i]], recording = FALSE)
15: grid.draw.gtable(x$children[[i]], recording = FALSE)
16: grid.draw(gt)
17: grid.draw.gTree(gt)
18: recordGraphics(drawGTree(x), list(x = x), getNamespace("grid"))
19: drawGTree(x)
20: grid.draw(x$children[[i]], recording = FALSE)
21: grid.draw.gTableChild(x$children[[i]], recording = FALSE)
22: pushViewport(x$wrapvp, recording = FALSE)
23: lapply(vps, push.vp, recording)
24: FUN(X[[1]], ...)
25: push.vp.viewport(X[[1]], ...)
26: grid.Call.graphics(L_setviewport, pvp, TRUE)

Selection: 0
>

Winston Chang

unread,
Sep 21, 2012, 4:23:48 PM9/21/12
to Trevor L Davis, ggp...@googlegroups.com
This problem is due a bug in grid where it doesn't like zero-size
viewports. A workaround for now is to use a nonzero size for
axis.ticks.margin, like this:
axis.ticks.margin = grid::unit(0.01, "cm")

The bug has been fixed in the development branch of R, so this problem
should go away in R 2.16.

For more info, see:
https://github.com/hadley/ggplot2/issues/636

-Winston
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
Reply all
Reply to author
Forward
0 new messages