#' Save a named plot
#'
#' This function saves a plot with name \emph{plot_name} as \emph{save_name} in
#' the directory \emph{save_path}
#'
#' @param plot_name A plot object
#' @param save_name Name, under which the plot is going to be saved
#' @param save_path Path, where the plot is going to be saved
#' @param format Optional file format (pdf, jpg, tiff), default is png
#' @param ratio_width_height Optional figure ratio widht to height, default is 1.618
#'
#' @author C. Sahin
#' @note Version 0, Creation 22.10.2019
#'
#' @example
#' testplot #
#' save_figure(testplot, saved_figure_name, path, pdf, 1.5)
#' @export
#'
#'
save_figure <- function(.plot_name, .save_name, .save_path,
.format = "png",
.ratio_width_height = 1.618){
# format figure height and width
height <- 3
width <- height*.ratio_width_height
ggsave(plot = .plot_name,
filename = sprintf("%s/%s.%s", .save_path, .save_name, .format),
scale = 1, width = width, height = height, units = "in", dpi = 300, limitsize = TRUE)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.