.build_options            package:ggplot2            R Documentation

_S_e_t _g_g_p_l_o_t _o_p_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     Set global options for ggplot.

_U_s_a_g_e:

     .build_options(opt)

_A_r_g_u_m_e_n_t_s:

     opt: list of options to get/set

_D_e_t_a_i_l_s:

     These are aliased into every plot object, so that \'p$grid.col'
     will return the default grid colour, unless it has been overriden
     for a particular plot object.  You can change the global options
     using the function, or the options for a specific plot by setting
     the values directly on the object.  See the examples for more
     details.

     Colour settings:

        *  axis.colour: axis text and line colour ("black")

        *  background.colour: background text colour ("black"), used
           for title

        *  background.fill:   background fill ("white")

        *  grid.colour: plot grid colour ("white")

        *  grid.fill:   plot grid background fill ("grey90")

     Strip settings

        *  strip.text:   function with two arguments (variable, and
           value) used for generating strip labels

        *  strip.gp: graphic parameter settings for the strip

        *  strip.text.gp:  graphic parameter settings for the strip
           text

     Legend settings

        *  legend.position:   position of legend: "none" to hide
           legend; "left", "right", "top", "bottom", for positioning
           outside of plot; c(x, y) for positioning on top of plot

        *  legend.justifcation: part of legend that position refers to

     Other settings:

        *  aspect.ratio: aspect ratio of facets.  Set to \'NULL' to
           allow to vary with device size

_A_u_t_h_o_r(_s):

     Hadley Wickham <h.wickham@gmail.com>

_E_x_a_m_p_l_e_s:

     ggopt(background.fill = "black", background.color ="white") # all new plots will use this
     p <- qplot(total_bill, tip, facet = smoker ~ sex, data=tips)
     p
     p$background.fill = "white"
     p
     p$strip.text.gp <- gpar(col="red", fontsize=15)
     p$strip.gp <- gpar(fill="black")
     p$background.fill <- "black"
     p$background.colour <- "white"
     p$grid.colour <- "white"
     p$grid.fill <- "grey50"
     p # a very ugly plot!
     ggopt(background.fill = "white", background.color ="black")

     p <- qplot(wt, mpg, data=mtcars, colour=factor(cyl))
     p$legend.position <- c(0.9,0.9); p
     p$legend.position <- c(0.5,0.5)
     p$legend.justification <- "center"
     p

     DF <- data.frame(
     x=rnorm(20), 
     y=rnorm(20), 
     g1=rep(letters[1:2], 10),
     g2=rep(LETTERS[1:2], each=10)
     )

     (p <- qplot(x, y, data=DF, facets = g1 ~ g2))

     p$strip.text <- function (variable, value) {
     greek <- c("A" = "alpha", "B" = "beta")[value]
     makelabel <- function (g) substitute(variable == greek, list(variable=as.name(variable), greek=as.name(g)))

     lapply(greek, makelabel)
     }

     p

