lines with = unit(0,"null") don't work anymore in gggplot2 0.9.2

173 views
Skip to first unread message

Roey Angel

unread,
Sep 15, 2012, 2:47:30 PM9/15/12
to ggp...@googlegroups.com
Hi!
I often use the following handy function to eliminate all background elements and have a whit background (copied it from somewhere on the internet):

opts_fullframe = function() {
  structure(list(panel.background = theme_blank(),
                 panel.grid.major = theme_blank(),
                 panel.grid.minor = theme_blank(),
                 panel.margin = unit(0,"null"),
                 plot.margin = rep(unit(0,"null"),4),
                 axis.ticks = theme_blank(),
                 axis.text.x = theme_blank(),
                 axis.text.y = theme_blank(),
                 axis.title.x = theme_blank(),
                 axis.title.y = theme_blank(),
                 axis.ticks.length = unit(0,"null"),
                 axis.ticks.margin = unit(0,"null")), class = "options")
}


As of ggplot2 0.9.2 this no longer works (gives error:
Error in p + o : non-numeric argument to binary operator
In addition: Warning message:
Incompatible methods ("+.gg", "Ops.unit") for "+"
)
Some debugging led me to realize that it's the lines with = unit(0,"null") which cause the problem.
What's the replacement for this in 0.9.2?

Thanks in advance,
Roey

p.s.
I know theme_blank() should also be replaced with element_blank().

Ben Bolker

unread,
Sep 15, 2012, 2:48:24 PM9/15/12
to ggp...@googlegroups.com
Did you remember library("grid") ?
(That might not be the problem but it's my first guess.)
> --
> 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

Roey Angel

unread,
Sep 15, 2012, 3:14:58 PM9/15/12
to ggp...@googlegroups.com
Thanks for the reply Ben but this doesn't seem to be it.
grid wasn't loaded but even after loading it the problem persists.

Roey

Roey Angel

unread,
Sep 19, 2012, 10:19:13 AM9/19/12
to ggp...@googlegroups.com
Correction. It seems the problem isn't (unit(0,"null")at all but rather with the change of object class from "options" to whatever it is (maybe "theme).
This seems to solve the problem:

blankground <- function() {
    theme(panel.background = element_blank(),
          panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),

          panel.margin = unit(0,"null"),
          plot.margin = rep(unit(0,"null"),4),
          axis.ticks = element_blank(),
          axis.text.x = element_blank(),
          axis.text.y = element_blank(),
          axis.title.x = element_blank(),
          axis.title.y = element_blank(),
          axis.ticks = element_blank()
          )

  }

Roey

On Saturday, September 15, 2012 8:47:30 PM UTC+2, Roey Angel wrote:
Reply all
Reply to author
Forward
0 new messages