Nothing
#' BdE theme for \CRANpkg{ggplot2}
#'
#' @description
#' A custom \CRANpkg{ggplot2} theme based on BdE publications.
#'
#' @inheritDotParams ggplot2::theme_classic
#'
#' @details
#' This theme extends [ggplot2::theme_classic()].
#'
#' @return A \CRANpkg{ggplot2} theme object.
#'
#' @seealso [ggplot2::theme_classic()] for the base theme extended here.
#'
#' @family bde_plot
#'
#' @importFrom ggplot2 %+replace% rel margin
#'
#' @encoding UTF-8
#' @export
#'
#' @examplesIf bde_check_access()
#' \donttest{
#' library(ggplot2)
#' library(dplyr)
#' library(tidyr)
#'
#' series_TC <- bde_series_full_load("TC_1_1.csv")
#'
#' # Plot if the download succeeds.
#' if (nrow(series_TC) > 0) {
#' series_TC <- series_TC[c(1, 2)]
#'
#' series_TC_pivot <- series_TC |>
#' filter(
#' Date >= "2020-01-01" & Date <= "2020-12-31",
#' !is.na(series_TC[[2]])
#' )
#'
#' names(series_TC_pivot) <- c("x", "y")
#'
#' ggplot(series_TC_pivot, aes(x = x, y = y)) +
#' geom_line(linewidth = 0.8, color = bde_tidy_palettes(n = 1)) +
#' labs(
#' title = "Title",
#' subtitle = "Some metric",
#' caption = "Banco de España"
#' ) +
#' theme_tidybde()
#' }
#' }
theme_tidybde <- function(...) {
ggplot2::theme_classic(...) %+replace%
ggplot2::theme(
line = element_line(linewidth = rel(0.5)),
plot.background = element_rect(fill = "white", colour = NA),
plot.margin = unit(rep(5.5, 4) * 3, "pt"),
plot.title = element_text(
margin = margin(b = 4),
hjust = 0,
vjust = 1,
size = rel(1.1)
),
plot.subtitle = element_text(
hjust = 0,
vjust = 1,
size = rel(0.9),
margin = margin(t = 4, b = 4)
),
plot.caption = element_text(hjust = 1, vjust = 0, size = rel(0.75)),
panel.background = element_rect(fill = "white", colour = NA),
panel.grid.major.y = element_line(colour = "grey70", linetype = "dashed"),
axis.title = element_blank(),
axis.ticks.length = unit(-2.75, "pt"),
axis.text.x.bottom = element_text(
margin = margin(t = 7.5, b = 5, unit = "pt"),
size = rel(0.9)
),
axis.text.x.top = element_text(
margin = margin(b = 7.5, t = 5, unit = "pt"),
size = rel(0.9)
),
axis.text.y.left = element_text(
hjust = 1,
margin = margin(r = 7.5, l = 5, unit = "pt"),
size = rel(0.9)
),
axis.text.y.right = element_text(
hjust = 0,
margin = margin(l = 7.5, r = 5, unit = "pt"),
size = rel(0.9)
),
legend.position = "bottom",
legend.justification = c(0, 0),
legend.title.align = 0,
legend.title = element_blank(),
legend.key = element_blank(),
legend.key.width = unit(25, "pt"),
legend.text = element_text(size = rel(0.9))
)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.