Skip to content

Commit

Permalink
update theme_nothing to ggplot 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
dkahle committed Dec 5, 2015
1 parent 67bca33 commit 2bf4c7f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
30 changes: 13 additions & 17 deletions R/theme_nothing.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#' Make a blank ggplot2 theme.
#'
#' theme_nothing simply strips all thematic element in ggplot2.
#'
#'
#' @param base_size base size, not used.
#' @param legend should the legend be included?
#' @return a ggplot2 theme (i.e., a list of class options).
#' @author David Kahle \email{david.kahle@@gmail.com}
#' @export
#' @examples
#' library(ggplot2)

#' \dontrun{
#'
#' n <- 50
Expand All @@ -17,23 +17,21 @@
#' p
#' p + theme_nothing()
#' p + theme_nothing(legend = TRUE) # no difference
#' p +
#' p +
#' scale_x_continuous(expand = c(0,0)) +
#' scale_y_continuous(expand = c(0,0)) +
#' theme_nothing()
#'
#' qplot(1:10,1:10) +
#' theme_nothing() +
#' theme(panel.background = element_rect(fill = "black"))
#'
#'
#'
#'
#'
#' df$class <- factor(sample(0:1, .5*n^2, replace = TRUE))
#' p <- qplot(x, y, data = df, geom = "tile", fill = class)
#' p
#' p + theme_nothing()
#' p + theme_nothing(legend = TRUE)
#'
#' p <- p +
#'
#' p <- p +
#' scale_x_continuous(expand = c(0,0)) +
#' scale_y_continuous(expand = c(0,0))
#' p
Expand All @@ -49,24 +47,22 @@ theme_nothing <- function(base_size = 12, legend = FALSE){
axis.title = element_blank(),
panel.background = element_blank(),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.grid.minor = element_blank(),
axis.ticks.length = unit(0, "cm"),
axis.ticks.margin = unit(0.01, "cm"), # change back to 0 when grid is fixed
panel.margin = unit(0, "lines"),
plot.margin = unit(c(0, 0, -.5, -.5), "lines"),
plot.margin = unit(c(0, 0, 0, 0), "lines"),
complete = TRUE
))
))
} else {
return(theme(
line = element_blank(),
rect = element_blank(),
text = element_blank(),
axis.ticks.length = unit(0, "cm"),
axis.ticks.margin = unit(0.01, "cm"), # change back to 0 when grid is fixed
legend.position = "none",
panel.margin = unit(0, "lines"),
plot.margin = unit(c(0, 0, -.5, -.5), "lines"),
plot.margin = unit(c(0, 0, 0, 0), "lines"),
complete = TRUE
))
}
}
}
9 changes: 3 additions & 6 deletions man/theme_nothing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bf4c7f

Please sign in to comment.