#' Charlotte's ggplot2 theme
#'
#' @description A standard theme to use for plots generated by this package.
#'
#' @param base_size `numeric`. Defines the overall size of the plot.
#' @param base_family `string`. Fontfamily to use, default is `"sans"`.
#' @param base_line_size `numeric`. Defines the line size to use.
#' @param base_rect_size `numeric`. Defines the rect size to use.
#' @param aspect_square `logical`. Should a square aspect ratio be used?
#' Default is `TRUE`.
#' @param border `logical`. Should the plot have a square border?
#' Default is `TRUE`.
#'
#' @return Returns a _theme_ object.
#' @export
#'
#' @examples
#' set.seed(11)
#' library(ggplot2)
#'
#' df <- diamonds[sample(nrow(diamonds), 1000), ]
#'
#' ggplot(df, aes(x = price, y = carat)) +
#' geom_point() +
#' theme_csd()
#'
theme_csd <- function(
base_size = 14,
base_family = "sans",
base_line_size = base_size / 18,
base_rect_size = base_size / 9,
aspect_square = TRUE,
border = TRUE
) {
out <- theme_classic(
base_size = base_size,
base_family = base_family,
base_line_size = base_line_size,
base_rect_size = base_rect_size
) %+replace%
theme(
axis.text = element_text(colour = "black")
)
if(aspect_square){
out <- out %+replace%
theme(aspect.ratio = 1)
}
if (border) {
out <- out %+replace%
theme(
panel.border = element_rect(colour = "black", fill = NA),
axis.line = element_blank()
)
}
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.