Skip to content
Browse files

Replace all theme_xx with element_xx

  • Loading branch information...
1 parent a56ecec commit 252b1081937eebdf88faf552cbf49aa347600545 @wch wch committed Jun 6, 2012
Showing with 41 additions and 41 deletions.
  1. +1 −1 R/annotation-custom.r
  2. +2 −2 R/annotation-logticks.r
  3. +1 −1 R/facet-grid-.r
  4. +1 −1 R/guide-colorbar.r
  5. +5 −5 R/guide-legend.r
  6. +28 −28 R/theme.r
  7. +1 −1 visual_test/guide-axis.r
  8. +2 −2 visual_test/guide-position.r
View
2 R/annotation-custom.r
@@ -34,7 +34,7 @@ NULL
#' }
#' # Inset plot
#' g <- ggplotGrob(qplot(1, 1) +
-#' theme(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)
annotation_custom <- function (grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf) {
View
4 R/annotation-logticks.r
@@ -39,15 +39,15 @@
#' 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") + theme(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
# plotting it. Also hide the minor grid lines.
#' 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()+ theme(panel.grid.minor = theme_blank())
+#' theme_bw()+ theme(panel.grid.minor = element_blank())
#'
#' b + annotation_logticks()
#'
View
2 R/facet-grid-.r
@@ -118,7 +118,7 @@
#' model <- reorder(model, cty)
#' manufacturer <- reorder(manufacturer, cty)
#' })
-#' last_plot() %+% mpg + theme(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()
View
2 R/guide-colorbar.r
@@ -67,7 +67,7 @@
#' 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))
View
10 R/guide-legend.r
@@ -16,7 +16,7 @@
#' title. One of "top" (default for a vertical guide), "bottom", "left"
#' (default for a horizontal guide), or "right."
#' @param title.theme A theme object for rendering the title text. Usually the
-#' object of \code{\link{theme_text}} is expected. By default, the theme is
+#' object of \code{\link{element_text}} is expected. By default, the theme is
#' specified by \code{legend.title} in \code{\link{theme}} or theme.
#' @param title.hjust A number specifying horizontal justification of the
#' title text.
@@ -28,7 +28,7 @@
#' label. One of "top", "bottom" (default for horizontal guide), "left", or
#' "right" (default for vertical gudie).
#' @param label.theme A theme object for rendering the label text. Usually the
-#' object of \code{\link{theme_text}} is expected. By default, the theme is
+#' object of \code{\link{element_text}} is expected. By default, the theme is
#' specified by \code{legend.text} in \code{\link{theme}} or theme.
#' @param label.hjust A numeric specifying horizontal justification of the
#' label text.
@@ -81,9 +81,9 @@
#' # 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"))
@@ -93,7 +93,7 @@
#' 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
#'
View
56 R/theme.r
@@ -90,7 +90,7 @@ print.theme <- function(x, ...) str(x)
#' \donttest{
#' p <- qplot(mpg, wt, data = mtcars)
#' p
-#' p + theme(panel_background = theme_rect(colour = "pink"))
+#' p + theme(panel_background = element_rect(colour = "pink"))
#' p + theme_bw()
#'
#' # Scatter plot of gas mileage by vehicle weight
@@ -115,8 +115,8 @@ print.theme <- function(x, ...) str(x)
#' p + theme(title = "Vehicle Weight-Gas Mileage Relationship")
#' # Change title appearance
#' p <- p + theme(title = "Vehicle Weight-Gas Mileage Relationship")
-#' p + theme(plot.title = theme_text(size = 20))
-#' p + theme(plot.title = theme_text(size = 20, colour = "Blue"))
+#' 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))
@@ -128,13 +128,13 @@ print.theme <- function(x, ...) str(x)
#'
#' # Manipulate Axis Attributes
#' library(grid) # for unit
-#' m + theme(axis.line = theme_segment())
-#' m + theme(axis.line = theme_segment(colour = "red", linetype = "dotted"))
-#' m + theme(axis.text.x = theme_text(colour = "blue"))
-#' m + theme(axis.text.y = theme_blank())
-#' m + theme(axis.ticks = theme_segment(size = 2))
-#' m + theme(axis.title.y = theme_text(size = 20, angle = 90))
-#' m + theme(axis.title.x = theme_blank())
+#' 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
@@ -145,39 +145,39 @@ print.theme <- function(x, ...) str(x)
#' # Or use relative coordinates between 0 and 1
#' z + theme(legend.position = c(.5, .5))
# # Add a border to the whole legend
-#' z + theme(legend.background = theme_rect())
+#' z + theme(legend.background = element_rect())
#' # Legend margin controls extra space around outside of legend:
-#' z + theme(legend.background = theme_rect(), legend.margin = unit(1, "cm"))
-#' z + theme(legend.background = theme_rect(), legend.margin = unit(0, "cm"))
+#' 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 = theme_rect())
-#' z + theme(legend.key = theme_rect(fill = "yellow"))
+#' 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 = theme_text(size = 20, colour = "red", angle = 45))
-#' z + theme(legend.title = theme_text(face = "italic"))
+#' 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 = theme_rect())
-#' z + theme(panel.background = theme_rect(fill = "black"))
-#' z + theme(panel.border = theme_rect(linetype = "dashed"))
-#' z + theme(panel.grid.major = theme_line(colour = "blue"))
-#' z + theme(panel.grid.minor = theme_line(colour = "red", linetype = "dotted"))
-#' z + theme(panel.grid.major = theme_line(size = 2))
-#' z + theme(plot.background = theme_rect())
-#' z + theme(plot.background = theme_rect(fill = "grey"))
+#' 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 = theme_rect(colour = "purple", fill = "pink", size = 3, linetype = "dashed"))
-#' k + theme(strip.text.x = theme_text(colour = "red", angle = 45, size = 10, hjust = 0.5, vjust = 0.5))
+#' 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"))
#' }
@@ -289,7 +289,7 @@ add_theme <- function(t1, t2) {
##' @return Updated theme element
##' @export
##' @examples
-##' x <- theme_text(size = 15)
+##' x <- element_text(size = 15)
##' update_element(x, colour = "red")
##' # Partial matching works
##' update_element(x, col = "red")
View
2 visual_test/guide-axis.r
@@ -9,7 +9,7 @@ save_vtest("align facet labels, facets horizontal")
qplot(reorder(model, hwy), hwy, data = mpg) +
facet_grid(. ~ manufacturer, scales = "free", space = "free") +
- theme(axis.text.x = theme_text(angle = 90, hjust = 1))
+ theme(axis.text.x = element_text(angle = 90, hjust = 1))
save_vtest("align facet labels, facets vertical")
end_vcontext()
View
4 visual_test/guide-position.r
@@ -1,6 +1,6 @@
vcontext("guide-position")
-p1 <- ggplot(mtcars, aes(mpg, disp, colour=cyl)) + geom_point() + theme(title = "title of plot", axis.text.x = theme_text(angle = 90)) +
+p1 <- ggplot(mtcars, aes(mpg, disp, colour=cyl)) + geom_point() + theme(title = "title of plot", axis.text.x = element_text(angle = 90)) +
scale_x_continuous(breaks = mean(mtcars$mpg), labels = "very very long long axis label") +
scale_y_continuous(breaks = mean(mtcars$disp), labels = "very very long long axis label")
@@ -34,7 +34,7 @@ save_vtest("facet_wrap, legend on top")
# padding
dat <- data.frame(x=LETTERS[1:3], y=1)
ggplot(dat, aes(x=x, y=y, fill=x, colour = 1:3)) + geom_bar() +
- theme(legend.background = theme_rect()) + guides(color = "colorbar")
+ theme(legend.background = element_rect()) + guides(color = "colorbar")
save_vtest("padding in legend box")
end_vcontext()

0 comments on commit 252b108

Please sign in to comment.
Something went wrong with that request. Please try again.