#' @importFrom graphics plot
#' @importFrom ggplot2 ggplot_add ggplot scale_colour_identity coord_fixed
#' @importFrom ggplot2 theme_void theme scale_fill_manual scale_size_identity
#' @export
plot.arch_tbl <- function(x,
label.direction = "inner",
colours = NULL,
xlim = c(-1.5, 1.4),
ylim = c(-1.25, 1.5),
...){
label.direction <- match.arg(label.direction, c("inner", "left_right"))
if(is.null(colours)) {
colours <- c("darkgreen", "green", "yellow", "red", "darkred")
}
pal <- grDevices::colorRampPalette(colours)
name <- unique(x$name)
values <- rlang::set_names(pal(nrow(x)), x$name)
if(label.direction != "inner") {
x$label.angle <- label_angle(x$angle, x$vertical)
}
x <- dplyr::arrange(x, id)
ggplot(x) +
geom_arch() +
geom_arch_label(...) +
scale_fill_manual(values = values) +
scale_size_identity(guide = "none") +
scale_colour_identity(guide = "none") +
coord_fixed(xlim = xlim, ylim = ylim) +
theme_void() +
theme(legend.position = "none")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.