The underlying data structures have changed, so that code won't work
anymore. You can use theme_bw as an example:
https://github.com/hadley/ggplot2/blob/ggplot2-0.9.2/R/theme-defaults.r
theme_bw <- function(base_size = 12, base_family = "") {
# Starts with theme_grey and then modify some parts
theme_grey(base_size = base_size, base_family = base_family) %+replace%
theme(
axis.text = element_text(size = rel(0.8)),
axis.ticks = element_line(colour = "black"),
legend.key = element_rect(colour = "grey80"),
panel.background = element_rect(fill = "white", colour = NA),
panel.border = element_rect(fill = NA, colour = "grey50"),
panel.grid.major = element_line(colour = "grey90", size = 0.2),
panel.grid.minor = element_line(colour = "grey98", size = 0.5),
strip.background = element_rect(fill = "grey80", colour = "grey50"),
strip.background = element_rect(fill = "grey80", colour = "grey50")
)
}
There's also a document that describes the changes:
https://github.com/wch/ggplot2/wiki/New-theme-system
-Winston
On Fri, Sep 7, 2012 at 6:22 PM, Xi <
xi.zhao...@gmail.com> wrote:
>
> Dear list,
>
> It used to be able to define/modify theme as in the following function
> myTheme.white() (see
https://github.com/hadley/ggplot2/wiki/Themes), but
> with the 0.9.2 version, it gets "Error: Don't know how to add o to a plot"
> (see below).
>
> By changing class = "theme" (or "themes") didnt´t work. Is it still possible
> to define theme in this way with the new release?
>
> Thanks for the help!
>
> Xi
>
>
>
> myTheme.white = function() { # theme_XX changed into element_XX for version
> 0.9.2
> structure(list(
> panel.background = element_rect(fill = "white", colour = NA),
> plot.background = element_rect(fill = "white", colour = NA),
> panel.grid.major = element_blank(),
> panel.grid.minor = element_blank(),
> legend.key = element_rect(colour=NA),
> strip.background = element_rect(colour = NA, fill=NA)
> ), class = "options")
> }
>
> #--------------------- example
>> df = data.frame(gp = factor(rep(letters[1:3], each = 10)), y = rnorm(30))
>> ggplot(df, aes(x = gp, y = y)) + geom_point() + myTheme.white()
> Error: Don't know how to add o to a plot
> #---------------------
>
>
>> sessionInfo()
> R version 2.15.1 (2012-06-22)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] C/en_US.UTF-8/C/C/C/C
>
> attached base packages:
> [1] grid splines stats graphics grDevices utils datasets
> methods base
>
> other attached packages:
> [1] scales_0.2.2 reshape2_1.2.1 plyr_1.7.1 Biobase_2.16.0
> BiocGenerics_0.2.0 ggplot2_0.9.2 survival_2.36-14
>
> loaded via a namespace (and not attached):
> [1] MASS_7.3-21 RColorBrewer_1.0-5 colorspace_1.1-1
> dichromat_1.2-4 digest_0.5.2 gtable_0.1.1 labeling_0.1
> [8] memoise_0.1 munsell_0.3 proto_0.3-9.2 stringr_0.6.1
> tools_2.15.1
>>
>
> --
> 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