Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Re-roxygenize

  • Loading branch information...
commit 6661a5b312810f719556cc422db4d0d29e2ad243 1 parent 252b108
Winston Chang wch authored
5 NAMESPACE
View
@@ -1,4 +1,6 @@
export("%+%")
+export("%+replace%")
+export("+.theme")
export(aes_all)
export(aes_auto)
export(aes_string)
@@ -11,6 +13,7 @@ export(annotation_raster)
export(autoplot)
export(benchplot)
export(borders)
+export(calc_element)
export(continuous_scale)
export(coord_cartesian)
export(coord_equal)
@@ -211,6 +214,7 @@ export(theme_segment)
export(theme_set)
export(theme_text)
export(theme_update)
+export(theme)
export(update_element)
export(update_geom_defaults)
export(update_labels)
@@ -231,7 +235,6 @@ importFrom(MASS,kde2d)
S3method("[",uneval)
S3method("+",ggplot)
S3method("+",theme)
-S3method("|",theme)
S3method(as.character,uneval)
S3method(autoplot,default)
S3method(cbind,gtable)
13 man/add_theme.Rd
View
@@ -0,0 +1,13 @@
+\name{add_theme}
+\alias{add_theme}
+\title{Modify properties of an element in a theme object}
+\usage{
+ add_theme(t1, t2)
+}
+\description{
+ Modify properties of an element in a theme object
+}
+\seealso{
+ +.theme
+}
+
2  man/annotation_custom.Rd
View
@@ -47,7 +47,7 @@ base + annotation_custom(grob = roundrectGrob(),
}
# Inset plot
g <- ggplotGrob(qplot(1, 1) +
- opts(plot.background = theme_rect(col = "black")))
+ theme(plot.background = element_rect(col = "black")))
base +
annotation_custom(grob = g, xmin = 1, xmax = 10, ymin = 8, ymax = 10)
}
4 man/annotation_logticks.Rd
View
@@ -54,14 +54,14 @@ a + annotation_logticks(sides = "lr") # Log ticks for y, on left and right
a + annotation_logticks(sides = "trbl") # All four sides
# Hide the minor grid lines because they don't align with the ticks
-a + annotation_logticks(sides = "trbl") + opts(panel.grid.minor = theme_blank())
+a + annotation_logticks(sides = "trbl") + theme(panel.grid.minor = element_blank())
# Another way to get the same results as 'a' above: log-transform the data before
b <- ggplot(Animals, aes(x = log10(body), y = log10(brain))) + geom_point() +
scale_x_continuous(name = "body", labels = math_format(10^.x)) +
scale_y_continuous(name = "brain", labels = math_format(10^.x)) +
- theme_bw()+ opts(panel.grid.minor = theme_blank())
+ theme_bw()+ theme(panel.grid.minor = element_blank())
b + annotation_logticks()
17 man/calc_element.Rd
View
@@ -0,0 +1,17 @@
+\name{calc_element}
+\alias{calc_element}
+\title{Calculate the element properties, by inheriting properties from its parents}
+\usage{
+ calc_element(element, theme)
+}
+\arguments{
+ \item{element}{The name of the theme element to
+ calculate}
+
+ \item{theme}{A theme object (like theme_grey())}
+}
+\description{
+ Calculate the element properties, by inheriting
+ properties from its parents
+}
+
2  man/coord_polar.Rd
View
@@ -49,7 +49,7 @@ ggplot(df, aes(x = "", y = value, fill = variable)) +
geom_bar(width = 1) +
scale_fill_manual(values = c("red", "yellow")) +
coord_polar("y", start=pi / 3) +
- opts(title = "Pac man")
+ theme(title = "Pac man")
# Windrose + doughnut plot
movies$rrating <- cut_interval(movies$rating, length = 1)
2  man/facet_grid.Rd
View
@@ -141,7 +141,7 @@ mpg <- within(mpg, {
model <- reorder(model, cty)
manufacturer <- reorder(manufacturer, cty)
})
-last_plot() \%+\% mpg + opts(strip.text.y = theme_text())
+last_plot() \%+\% mpg + theme(strip.text.y = element_text())
# Use as.table to to control direction of horizontal facets, TRUE by default
h <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()
4 man/facet_wrap.Rd
View
@@ -38,7 +38,7 @@
\examples{
\donttest{
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
- xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
+ xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)
d + facet_wrap(~ color)
d + facet_wrap(~ color, ncol = 1)
d + facet_wrap(~ color, ncol = 4)
@@ -54,7 +54,7 @@ d + facet_wrap(~ color, nrow = 3)
diamonds$color <- factor(diamonds$color, levels = c("G", "J", "D", "E", "I", "F", "H"))
# Repeat first example with new order
d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
-xlim(0, 2) + stat_binhex(na.rm = TRUE) + opts(aspect.ratio = 1)
+xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)
d + facet_wrap(~ color)
# You can choose to keep the scales constant across all panels
14 man/guide_colourbar.Rd
View
@@ -27,12 +27,12 @@
\item{barwidth}{A numeric or a unit object specifying the
width of the colorbar. Default value is
\code{legend.key.width} or \code{legend.key.size} in
- \code{\link{opts}} or theme.}
+ \code{\link{theme}} or theme.}
\item{barheight}{A numeric or a unit object specifying
the height of the colorbar. Default value is
\code{legend.key.height} or \code{legend.key.size} in
- \code{\link{opts}} or theme.}
+ \code{\link{theme}} or theme.}
\item{nbin}{A numeric specifying the number of bins for
drawing colorbar. A smoother colorbar for a larger
@@ -78,9 +78,9 @@
guide), or "right."}
\item{title.theme}{A theme object for rendering the title
- text. Usually the object of \code{\link{theme_text}} is
+ text. Usually the object of \code{\link{element_text}} is
expected. By default, the theme is specified by
- \code{legend.title} in \code{\link{opts}} or theme.}
+ \code{legend.title} in \code{\link{theme}} or theme.}
\item{title.hjust}{A number specifying horizontal
justification of the title text.}
@@ -97,9 +97,9 @@
vertical gudie).}
\item{label.theme}{A theme object for rendering the label
- text. Usually the object of \code{\link{theme_text}} is
+ text. Usually the object of \code{\link{element_text}} is
expected. By default, the theme is specified by
- \code{legend.text} in \code{\link{opts}} or theme.}
+ \code{legend.text} in \code{\link{theme}} or theme.}
\item{label.hjust}{A numeric specifying horizontal
justification of the label text.}
@@ -153,7 +153,7 @@ p1 + guides(fill = guide_colorbar(ticks = FALSE))
p1 + guides(fill = guide_colorbar(label.position = "left"))
# label theme
-p1 + guides(fill = guide_colorbar(label.theme = theme_text(col="blue")))
+p1 + guides(fill = guide_colorbar(label.theme = element_text(col="blue")))
# small number of bins
p1 + guides(fill = guide_colorbar(nbin = 3))
18 man/guide_legend.Rd
View
@@ -25,9 +25,9 @@
guide), or "right."}
\item{title.theme}{A theme object for rendering the title
- text. Usually the object of \code{\link{theme_text}} is
+ text. Usually the object of \code{\link{element_text}} is
expected. By default, the theme is specified by
- \code{legend.title} in \code{\link{opts}} or theme.}
+ \code{legend.title} in \code{\link{theme}} or theme.}
\item{title.hjust}{A number specifying horizontal
justification of the title text.}
@@ -44,9 +44,9 @@
vertical gudie).}
\item{label.theme}{A theme object for rendering the label
- text. Usually the object of \code{\link{theme_text}} is
+ text. Usually the object of \code{\link{element_text}} is
expected. By default, the theme is specified by
- \code{legend.text} in \code{\link{opts}} or theme.}
+ \code{legend.text} in \code{\link{theme}} or theme.}
\item{label.hjust}{A numeric specifying horizontal
justification of the label text.}
@@ -57,12 +57,12 @@
\item{keywidth}{A numeric or a unit object specifying the
width of the legend key. Default value is
\code{legend.key.width} or \code{legend.key.size} in
- \code{\link{opts}} or theme.}
+ \code{\link{theme}} or theme.}
\item{keyheight}{A numeric or a unit object specifying
the height of the legend key. Default value is
\code{legend.key.height} or \code{legend.key.size} in
- \code{\link{opts}} or theme.}
+ \code{\link{theme}} or theme.}
\item{direction}{A character string indicating the
direction of the guide. One of "horizontal" or
@@ -128,9 +128,9 @@ p1 + guides(fill = guide_legend(keywidth = 3, keyheight = 1))
# title position
p1 + guides(fill = guide_legend(title = "LEFT", title.position = "left"))
-# title text styles via theme_text
+# title text styles via element_text
p1 + guides(fill = guide_legend(
- title.theme = theme_text(size=15, face="italic", col="red", angle=45)))
+ title.theme = element_text(size=15, face="italic", col="red", angle=45)))
# label position
p1 + guides(fill = guide_legend(label.position = "bottom"))
@@ -140,7 +140,7 @@ p1 + scale_fill_continuous(breaks = c(5, 10, 15),
labels = paste("long", c(5, 10, 15)),
guide = guide_legend(direction = "horizontal", title.position = "top",
label.position="bottom", label.hjust = 0.5, label.vjust = 0.5,
- label.theme = theme_text(angle = 90)))
+ label.theme = element_text(angle = 90)))
# Set aesthetic of legend key
4 man/guides.Rd
View
@@ -45,11 +45,11 @@ p + guides(colour = guide_legend("title"), size = guide_legend("title"),
g <- guide_legend("title")
p + guides(colour = g, size = g, shape = g)
-p + opts(legend.position = "bottom")
+p + theme(legend.position = "bottom")
# position of guides
-p + opts(legend.position = "bottom", legend.box = "horizontal")
+p + theme(legend.position = "bottom", legend.box = "horizontal")
}
}
\seealso{
144 man/opts.Rd
View
@@ -1,149 +1,11 @@
\name{opts}
\alias{opts}
-\title{Set options/theme elements for a single plot}
+\title{Build a theme (or partial theme) from theme elements}
\usage{
opts(...)
}
-\arguments{
- \item{...}{a list of element name, element pairings that
- modify the existing theme.}
-}
\description{
- Use this function if you want to modify a few theme
- settings for a single plot.
-}
-\section{Theme elements}{
- The individual theme elements are:
-
- \tabular{ll}{ axis.line \tab line along axis \cr
- axis.title.x \tab x axis label \cr axis.title.y \tab y
- axis label \cr axis.ticks \tab axis tick marks \cr
- axis.ticks.length \tab tick mark length \cr
- axis.ticks.margin \tab tick mark margin spacing \cr
- axis.text.x \tab horizontal tick labels \cr axis.text.y
- \tab vertical tick labels \cr legend.background \tab
- background of legend \cr legend.margin \tab extra space
- added around legend (both width or height depending on
- orientation of legend) \cr legend.key \tab background
- underneath legend keys \cr legend.key.size \tab key
- background size \cr legend.key.height \tab key background
- height \cr legend.key.width \tab key background width \cr
- legend.text \tab legend labels \cr legend.text.align \tab
- alignment of legend labels \cr legend.title \tab legend
- name \cr legend.title.align \tab alignment of legend
- title \cr legend.position \tab A string or numeric vector
- specifying the position of guides (legends). Possible
- values are: "left", "right", "bottom", "top", and
- two-element numeric vector. \cr legend.justification \tab
- alignment of legend \cr legend.direction \tab horizontal
- or vertical \cr legend.box \tab A string specifying the
- direction of multiple guides. Possible string values are:
- "horizontal" and "vertical". \cr panel.background \tab
- background of panel \cr panel.border \tab border around
- panel \cr panel.margin \tab margin around facet panels
- \cr panel.grid.major \tab major grid lines \cr
- panel.grid.minor \tab minor grid lines \cr
- plot.background \tab background of the entire plot \cr
- plot.title \tab plot title (text appearance) \cr
- plot.margin \tab plot margins \cr strip.background \tab
- background of facet labels \cr strip.text.x \tab text for
- horizontal strips \cr strip.text.y \tab text for vertical
- strips \cr title \tab A string containing the title of
- the plot \cr }
-}
-\examples{
-\donttest{
-p <- qplot(mpg, wt, data = mtcars)
-p
-p + opts(panel_background = theme_rect(colour = "pink"))
-p + theme_bw()
-
-# Scatter plot of gas mileage by vehicle weight
-p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
-# Calculate slope and intercept of line of best fit
-coef(lm(mpg ~ wt, data = mtcars))
-p + geom_abline(intercept = 37, slope = -5)
-# Calculate correlation coefficient
-with(mtcars, cor(wt, mpg, use = "everything", method = "pearson"))
-#annotate the plot
-p + geom_abline(intercept = 37, slope = -5) +
-geom_text(data = data.frame(), aes(4.5, 30, label = "Pearson-R = -.87"))
-
-# Change the axis labels
-# Original plot
-p
-p + xlab("Vehicle Weight") + ylab("Miles per Gallon")
-# Or
-p + labs(x = "Vehicle Weight", y = "Miles per Gallon")
-
-# Add a title to the plot
-p + opts(title = "Vehicle Weight-Gas Mileage Relationship")
-# Change title appearance
-p <- p + opts(title = "Vehicle Weight-Gas Mileage Relationship")
-p + opts(plot.title = theme_text(size = 20))
-p + opts(plot.title = theme_text(size = 20, colour = "Blue"))
-
-# Changing plot look with themes
-DF <- data.frame(x = rnorm(400))
-m <- ggplot(DF, aes(x = x)) + geom_histogram()
-#default is theme_grey()
-m
-# Compare with
-m + theme_bw()
-
-# Manipulate Axis Attributes
-library(grid) # for unit
-m + opts(axis.line = theme_segment())
-m + opts(axis.line = theme_segment(colour = "red", linetype = "dotted"))
-m + opts(axis.text.x = theme_text(colour = "blue"))
-m + opts(axis.text.y = theme_blank())
-m + opts(axis.ticks = theme_segment(size = 2))
-m + opts(axis.title.y = theme_text(size = 20, angle = 90))
-m + opts(axis.title.x = theme_blank())
-m + opts(axis.ticks.length = unit(.85, "cm"))
-
-# Legend Attributes
-z <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point()
-z
-z + opts(legend.position = "none")
-z + opts(legend.position = "bottom")
-# Or use relative coordinates between 0 and 1
-z + opts(legend.position = c(.5, .5))
-z + opts(legend.background = theme_rect())
-# Legend margin controls extra space around outside of legend:
-z + opts(legend.background = theme_rect(), legend.margin = unit(1, "cm"))
-z + opts(legend.background = theme_rect(), legend.margin = unit(0, "cm"))
-# Or to just the keys
-z + opts(legend.key = theme_rect())
-z + opts(legend.key = theme_rect(fill = "yellow"))
-z + opts(legend.key.size = unit(2.5, "cm"))
-z + opts(legend.text = theme_text(size = 20, colour = "red", angle = 45))
-z + opts(legend.title = theme_text(face = "italic"))
-
-# To change the title of the legend use the name argument
-# in one of the scale options
-z + scale_colour_brewer(name = "My Legend")
-z + scale_colour_grey(name = "Number of \\nCylinders")
-
-# Panel and Plot Attributes
-z + opts(panel.background = theme_rect())
-z + opts(panel.background = theme_rect(fill = "black"))
-z + opts(panel.border = theme_rect(linetype = "dashed"))
-z + opts(panel.grid.major = theme_line(colour = "blue"))
-z + opts(panel.grid.minor = theme_line(colour = "red", linetype = "dotted"))
-z + opts(panel.grid.major = theme_line(size = 2))
-z + opts(plot.background = theme_rect())
-z + opts(plot.background = theme_rect(fill = "grey"))
-
-# Faceting Attributes
-set.seed(4940)
-dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
-k <- ggplot(dsmall, aes(carat, ..density..)) + geom_histogram(binwidth = 0.2) +
-facet_grid(. ~ cut)
-k + opts(strip.background = theme_rect(colour = "purple", fill = "pink", size = 3, linetype = "dashed"))
-k + opts(strip.text.x = theme_text(colour = "red", angle = 45, size = 10, hjust = 0.5, vjust = 0.5))
-k + opts(panel.margin = unit(5, "lines"))
-k + opts(panel.margin = unit(0, "lines"))
-}
+ \code{opts} is deprecated. See the \code{\link{theme}}
+ function.
}
2  man/scale_date.Rd
View
@@ -43,7 +43,7 @@ df <- data.frame(
price = runif(50)
)
df <- df[order(df$date), ]
-dt <- qplot(date, price, data=df, geom="line") + opts(aspect.ratio = 1/4)
+dt <- qplot(date, price, data=df, geom="line") + theme(aspect.ratio = 1/4)
# We can control the format of the labels, and the frequency of
# the major and minor tickmarks. See ?format.Date and ?seq.Date
26 man/theme-add.Rd
View
@@ -1,18 +1,36 @@
\name{+.theme}
+\alias{\%+replace\%}
\alias{+.theme}
-\title{Modify a theme object}
+\title{Modify elements in a theme object}
\usage{
+.theme(e1, e2)
+
+ %+replace%(e1, e2)
}
\arguments{
\item{e1}{theme object}
- \item{e2}{theme object to add}
+ \item{e2}{theme object to use for updating e1}
}
\description{
- Modify a theme object
+ The \code{+} operator and the \code{\%+replace\%} can be
+ used to modify elements in themes.
+}
+\details{
+ The \code{+} operator completely replaces elements with
+ elements from e2.
+
+ In contrast, the \code{\%+replace\%} operator does not
+ replace the entire element; it only updates element
+ properties which are present (not NULL) in the second
+ object.
}
\examples{
-mytheme <- theme_grey() + opts(axis.title.x = element_text(family = "Times"))
+# Compare these results
+add_el <- theme_grey() + theme(text = element_text(family = "Times"))
+rep_el <- theme_grey() \%+replace\% theme(text = element_text(family = "Times"))
+
+add_el$text
+rep_el$text
}
26 man/theme-element-update.Rd
View
@@ -1,26 +0,0 @@
-\name{|.theme}
-\alias{|.theme}
-\title{Modify properties of an element in a theme object}
-\usage{
- |.theme(t1, t2)
-}
-\arguments{
- \item{e1}{theme object}
-
- \item{e2}{theme object to use for updating}
-}
-\description{
- In contrast with the \code{+.theme} operator, this
- operator does not replace the entire element; it only
- updates element properties which are present (not NULL)
- in the second object.
-}
-\examples{
-# Compare these results
-mod_el <- theme_grey() | opts(text = element_text(family = "Times"))
-add_el <- theme_grey() + opts(text = element_text(family = "Times"))
-
-mod_el$text
-add_el$text
-}
-
149 man/theme.Rd
View
@@ -0,0 +1,149 @@
+\name{theme}
+\alias{theme}
+\title{Set options/theme elements for a single plot}
+\usage{
+ theme(...)
+}
+\arguments{
+ \item{...}{a list of element name, element pairings that
+ modify the existing theme.}
+}
+\description{
+ Use this function if you want to modify a few theme
+ settings for a single plot.
+}
+\section{Theme elements}{
+ The individual theme elements are:
+
+ \tabular{ll}{ axis.line \tab line along axis \cr
+ axis.title.x \tab x axis label \cr axis.title.y \tab y
+ axis label \cr axis.ticks \tab axis tick marks \cr
+ axis.ticks.length \tab tick mark length \cr
+ axis.ticks.margin \tab tick mark margin spacing \cr
+ axis.text.x \tab horizontal tick labels \cr axis.text.y
+ \tab vertical tick labels \cr legend.background \tab
+ background of legend \cr legend.margin \tab extra space
+ added around legend (both width or height depending on
+ orientation of legend) \cr legend.key \tab background
+ underneath legend keys \cr legend.key.size \tab key
+ background size \cr legend.key.height \tab key background
+ height \cr legend.key.width \tab key background width \cr
+ legend.text \tab legend labels \cr legend.text.align \tab
+ alignment of legend labels \cr legend.title \tab legend
+ name \cr legend.title.align \tab alignment of legend
+ title \cr legend.position \tab A string or numeric vector
+ specifying the position of guides (legends). Possible
+ values are: "left", "right", "bottom", "top", and
+ two-element numeric vector. \cr legend.justification \tab
+ alignment of legend \cr legend.direction \tab horizontal
+ or vertical \cr legend.box \tab A string specifying the
+ direction of multiple guides. Possible string values are:
+ "horizontal" and "vertical". \cr panel.background \tab
+ background of panel \cr panel.border \tab border around
+ panel \cr panel.margin \tab margin around facet panels
+ \cr panel.grid.major \tab major grid lines \cr
+ panel.grid.minor \tab minor grid lines \cr
+ plot.background \tab background of the entire plot \cr
+ plot.title \tab plot title (text appearance) \cr
+ plot.margin \tab plot margins \cr strip.background \tab
+ background of facet labels \cr strip.text.x \tab text for
+ horizontal strips \cr strip.text.y \tab text for vertical
+ strips \cr title \tab A string containing the title of
+ the plot \cr }
+}
+\examples{
+\donttest{
+p <- qplot(mpg, wt, data = mtcars)
+p
+p + theme(panel_background = element_rect(colour = "pink"))
+p + theme_bw()
+
+# Scatter plot of gas mileage by vehicle weight
+p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
+# Calculate slope and intercept of line of best fit
+coef(lm(mpg ~ wt, data = mtcars))
+p + geom_abline(intercept = 37, slope = -5)
+# Calculate correlation coefficient
+with(mtcars, cor(wt, mpg, use = "everything", method = "pearson"))
+#annotate the plot
+p + geom_abline(intercept = 37, slope = -5) +
+geom_text(data = data.frame(), aes(4.5, 30, label = "Pearson-R = -.87"))
+
+# Change the axis labels
+# Original plot
+p
+p + xlab("Vehicle Weight") + ylab("Miles per Gallon")
+# Or
+p + labs(x = "Vehicle Weight", y = "Miles per Gallon")
+
+# Add a title to the plot
+p + theme(title = "Vehicle Weight-Gas Mileage Relationship")
+# Change title appearance
+p <- p + theme(title = "Vehicle Weight-Gas Mileage Relationship")
+p + theme(plot.title = element_text(size = 20))
+p + theme(plot.title = element_text(size = 20, colour = "Blue"))
+
+# Changing plot look with themes
+DF <- data.frame(x = rnorm(400))
+m <- ggplot(DF, aes(x = x)) + geom_histogram()
+#default is theme_grey()
+m
+# Compare with
+m + theme_bw()
+
+# Manipulate Axis Attributes
+library(grid) # for unit
+m + theme(axis.line = element_segment())
+m + theme(axis.line = element_segment(colour = "red", linetype = "dotted"))
+m + theme(axis.text.x = element_text(colour = "blue"))
+m + theme(axis.text.y = element_blank())
+m + theme(axis.ticks = element_segment(size = 2))
+m + theme(axis.title.y = element_text(size = 20, angle = 90))
+m + theme(axis.title.x = element_blank())
+m + theme(axis.ticks.length = unit(.85, "cm"))
+
+# Legend Attributes
+z <- ggplot(mtcars, aes(wt, mpg, colour = factor(cyl))) + geom_point()
+z
+z + theme(legend.position = "none")
+z + theme(legend.position = "bottom")
+# Or use relative coordinates between 0 and 1
+z + theme(legend.position = c(.5, .5))
+z + theme(legend.background = element_rect())
+# Legend margin controls extra space around outside of legend:
+z + theme(legend.background = element_rect(), legend.margin = unit(1, "cm"))
+z + theme(legend.background = element_rect(), legend.margin = unit(0, "cm"))
+# Or to just the keys
+z + theme(legend.key = element_rect())
+z + theme(legend.key = element_rect(fill = "yellow"))
+z + theme(legend.key.size = unit(2.5, "cm"))
+z + theme(legend.text = element_text(size = 20, colour = "red", angle = 45))
+z + theme(legend.title = element_text(face = "italic"))
+
+# To change the title of the legend use the name argument
+# in one of the scale options
+z + scale_colour_brewer(name = "My Legend")
+z + scale_colour_grey(name = "Number of \\nCylinders")
+
+# Panel and Plot Attributes
+z + theme(panel.background = element_rect())
+z + theme(panel.background = element_rect(fill = "black"))
+z + theme(panel.border = element_rect(linetype = "dashed"))
+z + theme(panel.grid.major = element_line(colour = "blue"))
+z + theme(panel.grid.minor = element_line(colour = "red", linetype = "dotted"))
+z + theme(panel.grid.major = element_line(size = 2))
+z + theme(plot.background = element_rect())
+z + theme(plot.background = element_rect(fill = "grey"))
+
+# Faceting Attributes
+set.seed(4940)
+dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
+k <- ggplot(dsmall, aes(carat, ..density..)) + geom_histogram(binwidth = 0.2) +
+facet_grid(. ~ cut)
+k + theme(strip.background = element_rect(colour = "purple", fill = "pink", size = 3, linetype = "dashed"))
+k + theme(strip.text.x = element_text(colour = "red", angle = 45, size = 10, hjust = 0.5, vjust = 0.5))
+k + theme(panel.margin = unit(5, "lines"))
+k + theme(panel.margin = unit(0, "lines"))
+}
+}
+
4 man/theme_update.Rd
View
@@ -33,8 +33,8 @@ theme_set(old)
theme_get()
qplot(mpg, wt, data=mtcars, colour=mpg) +
- opts(legend.position=c(0.95, 0.95), legend.justification = c(1, 1))
+ theme(legend.position=c(0.95, 0.95), legend.justification = c(1, 1))
last_plot() +
- opts(legend.background = element_rect(fill = "white", col="white", size = 3))
+ theme(legend.background = element_rect(fill = "white", col="white", size = 3))
}
6 man/translate_qplot_base.Rd
View
@@ -111,7 +111,7 @@ last_plot() + geom_line()
# In ggplot2, the appearance of legends and axes is controlled by the scales.
# Axes are produced by the x and y scales, while all other scales produce legends.
-# See ?opts for help changing the appearance of axes and legends.
+# See ?theme for help changing the appearance of axes and legends.
# The appearance of grid lines is controlled by the grid.major and grid.minor
# theme options, and their position by the breaks of the x and y scales.
@@ -142,8 +142,8 @@ last_plot() + scale_colour_gradientn(colours = terrain.colors(7))
# in the defaults of the geoms and scales. The appearance plot border drawn
# by box() can be controlled in a similar way by the panel.background and
# plot.background theme elements. Instead of using title(), the plot title is
-# set with the title option. See ?opts for more theme elements.
-last_plot() + opts(title = "My Plot Title")
+# set with the title option. See ?theme for more theme elements.
+last_plot() + theme(title = "My Plot Title")
}
}
4 man/translate_qplot_ggplot.Rd
View
@@ -77,8 +77,8 @@
# Plot options
# qplot() recognises the same options as plot does, and converts them to their
-# ggplot2 equivalents. See ?opts for more on ggplot options
+# ggplot2 equivalents. See ?theme for more on ggplot options
# qplot(x, y, data = data, main="title", asp = 1)
-# ggplot(data, aes(x, y)) + geom_point() + opts(title = "title", aspect.ratio = 1)
+# ggplot(data, aes(x, y)) + geom_point() + theme(title = "title", aspect.ratio = 1)
}
2  man/translate_qplot_lattice.Rd
View
@@ -67,7 +67,7 @@ qplot(mpg, wt, data = mtcars, xlab = "Miles per gallon", ylab = "Weight",
xyplot(wt ~ mpg, mtcars, aspect = 1)
qplot(mpg, wt, data = mtcars, asp = 1)
-# par.settings() is equivalent to + opts() and trellis.options.set()
+# par.settings() is equivalent to + theme() and trellis.options.set()
# and trellis.par.get() to theme_set() and theme_get().
# More complicated lattice formulas are equivalent to rearranging the data
# before using ggplot2.
2  man/update_element.Rd
View
@@ -16,7 +16,7 @@
Update contents of a theme
}
\examples{
-x <- theme_text(size = 15)
+x <- element_text(size = 15)
update_element(x, colour = "red")
# Partial matching works
update_element(x, col = "red")
Please sign in to comment.
Something went wrong with that request. Please try again.