Skip to content

Commit

Permalink
update theme
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Dec 25, 2019
1 parent d030db3 commit 0b7e8bb
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Imports:
graphics,
magrittr,
rlang,
methods,
utils
Suggests:
stats,
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

S3method("+",bbplot)
S3method("<=",bb_theme)
S3method(bbplot_add,bb_labs)
S3method(bbplot_add,bb_layer)
S3method(bbplot_add,bb_theme)
Expand Down Expand Up @@ -30,6 +31,7 @@ importFrom(graphics,points)
importFrom(graphics,segments)
importFrom(graphics,title)
importFrom(magrittr,"%>%")
importFrom(methods,is)
importFrom(rlang,enquos)
importFrom(rlang,quo_name)
importFrom(utils,modifyList)
8 changes: 7 additions & 1 deletion R/add-layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ add_layer <- function(plot, layer, layer_name) {
return(plot)
}


##' @method <= bb_theme
##' @importFrom methods is
##' @export
`<=.bb_theme` <- function(e1, e2) {
stopifnot(is(e2, "bb_theme"))
modifyList(e1, e2)
}
17 changes: 8 additions & 9 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,42 @@ bb_theme <- function(...) {
##' @method bbplot_add bb_theme
##' @export
bbplot_add.bb_theme <- function(object, plot) {
plot$theme <- modifyList(plot$theme, object)
plot$theme <- plot$theme <= object
plot
}


##' @rdname bb-theme
##' @export
bb_theme_expand <- function(...) {
theme_default <- bb_theme(
bb_theme(
mar=c(3,3,2,1),
mgp=c(2,0.4,0),
tck=-.01,
cex.axis=.9
)
modifyList(theme_default, bb_theme(...))
) <= bb_theme(...)
}

##' @rdname bb-theme
##' @export
bb_theme_grey <- function(...) {
theme_default <- bb_theme(
bb_theme(
cex.axis = .9,
bg = "grey85",
fg = "grey20",
col.axis = "grey20",
col.lab = "grey20"
)
modifyList(theme_default, bb_theme(...))
) <= bb_theme(...)
}

##' @rdname bb-theme
##' @export
bb_theme_deepblue <- function(...) {
theme_default <- bb_theme(
bb_theme(
bg = "#002E49",
fg = "#CCCCCC",
col.axis = "#BEBEBE",
col.lab = "#FFFFFF"
)
) <= bb_theme(...)
}

0 comments on commit 0b7e8bb

Please sign in to comment.