7057aa91 |
##' tree theme
##'
|
2b0f27d5 |
##'
|
7057aa91 |
##' @title theme_tree
##' @param bgcolor background color
##' @param fgcolor foreground color
##' @param ... additional parameter
##' @importFrom ggplot2 theme_bw
##' @importFrom ggplot2 theme
##' @importFrom ggplot2 element_blank
|
16dd3ab8 |
##' @importFrom ggplot2 xlab
##' @importFrom ggplot2 ylab
|
7057aa91 |
##' @export
##' @return updated ggplot object with new theme
##' @author Yu Guangchuang
##' @examples
##' require(ape)
##' tr <- rtree(10)
##' ggtree(tr) + theme_tree()
theme_tree <- function(bgcolor="white", fgcolor="black", ...) {
|
16dd3ab8 |
list(xlab(NULL),
ylab(NULL),
|
bedefde1 |
theme_tree2_internal() +
theme(panel.background=element_rect(fill=bgcolor, colour=bgcolor),
axis.line.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
...)
|
16dd3ab8 |
)
|
7057aa91 |
}
##' tree2 theme
##'
|
2b0f27d5 |
##'
|
7057aa91 |
##' @title theme_tree2
##' @param bgcolor background color
##' @param fgcolor foreground color
##' @param ... additional parameter
##' @importFrom ggplot2 theme_bw
##' @importFrom ggplot2 theme
##' @importFrom ggplot2 element_blank
##' @importFrom ggplot2 element_line
##' @importFrom ggplot2 element_rect
##' @export
##' @return updated ggplot object with new theme
##' @author Yu Guangchuang
##' @examples
##' require(ape)
##' tr <- rtree(10)
##' ggtree(tr) + theme_tree2()
theme_tree2 <- function(bgcolor="white", fgcolor="black", ...) {
|
16dd3ab8 |
list(xlab(NULL),
ylab(NULL),
theme_tree2_internal(bgcolor, fgcolor, ...)
)
}
|
2b0f27d5 |
theme_tree2_internal <- function(bgcolor="white", fgcolor="black",
legend.position="none",
panel.grid.minor=element_blank(),
panel.grid.major=element_blank(),
panel.border=element_blank(),
axis.line.y=element_blank(),
axis.ticks.y=element_blank(),
axis.text.y=element_blank(),...) {
|
bedefde1 |
theme_bw() +
theme(legend.position=legend.position,
panel.grid.minor=panel.grid.minor,
panel.grid.major=panel.grid.major,
panel.background=element_rect(fill=bgcolor, colour=bgcolor),
panel.border=panel.border,
## axis.line=element_line(color=fgcolor),
axis.line.x=element_line(color=fgcolor),
axis.line.y=axis.line.y,
axis.ticks.y=axis.ticks.y,
axis.text.y=axis.text.y,
...)
|
7057aa91 |
}
##' transparent background theme
##'
|
2b0f27d5 |
##'
|
7057aa91 |
##' @title theme_transparent
##' @param ... additional parameter to tweak the theme
##' @return ggplot object
##' @importFrom ggplot2 theme
##' @importFrom ggplot2 element_rect
##' @export
##' @author Guangchuang Yu
theme_transparent <- function(...) {
theme(panel.background = element_rect(
fill = "transparent",
colour = NA),
plot.background = element_rect(
fill = "transparent",
|
275491b1 |
colour = NA),
legend.key = element_rect(
fill = "transparent",
colour = NA),
legend.background = element_rect(
fill = "transparent",
|
7057aa91 |
colour = NA), ...)
}
|
d5c2a530 |
##' inset theme
##'
##' theme for inset function
##' @title theme_inset
##' @param ... additional parameter
##' @return ggplot object
##' @export
##' @author Guangchuang Yu
theme_inset <- function(...) {
list(xlab(NULL),
ylab(NULL),
theme_tree(...),
theme_transparent()
)
}
|