save_Plot: Save a plot as png, pdf and svg.

View source: R/save_Plot.R

save_PlotR Documentation

Save a plot as png, pdf and svg.

Description

Save a plot as png, pdf and svg.

Usage

save_Plot(
  plot,
  figure_path = NULL,
  create_path = TRUE,
  file_name = NULL,
  dpi = 300,
  output_format = "publication",
  width = 8,
  height = 8
)

Arguments

plot

Plot to save.

figure_path

character | Path where the figure will be stored.

create_path

logical | Whether to create the path.

file_name

character | Name of the file (without extension, it will be added automatically).

dpi

numeric | Dpi to use.

output_format

character | Output format of the saved figure. One of:

  • pdf: Saves the figure as a PDF file.

  • png: Saves the figure as a PNG file.

  • jpeg: Saves the figure as a JPEG file.

  • tiff: Saves the figure as a TIFF file.

  • svg: Saves the figure as a SVG file.

  • publication: Saves the figure as PDF, PNG and SVG files.

  • all: Saves the figure in all possible formats.

width, height

numeric | Width and height of the figure (inches).

Value

Nothing.

Examples

## Not run: 
  # Check Suggests.
  value <- SCpubr:::check_suggests(function_name = "save_Plot", passive = TRUE)

  if (isTRUE(value)){
    # Define your Seurat object.
    sample <- readRDS(system.file("extdata/seurat_dataset_example.rds", package = "SCpubr"))

    # Generate a plot.
    p <- SCpubr::do_DimPlot(sample = sample)

    # Default parameters.
    SCpubr::save_Plot(plot = p)

    # Specifying the name and folder.
    SCpubr::save_Plot(plot = p,
                      figure_path = "/path/to/my/figures/",
                      file_name = "my_figure")

    # Specify to also create a new folder.
    SCpubr::save_Plot(plot = p,
                      figure_path = "/path/to/my/figures/",
                      file_name = "my_figure",
                      create_path = TRUE)

    # Set dimensions for the figure.
    SCpubr::save_Plot(plot = p,
                      figure_path = "/path/to/my/figures/",
                      file_name = "my_figure",
                      create_path = TRUE,
                      width = 8,
                      height = 8)

    # Set quality (dpi).
    SCpubr::save_Plot(plot = p,
                      figure_path = "/path/to/my/figures/",
                      file_name = "my_figure",
                      create_path = TRUE,
                      width = 8,
                      height = 8,
                      dpi = 300)
  } else if (base::isFALSE(value)){
    message("This function can not be used without its suggested packages.")
    message("Check out which ones are needed using `SCpubr::state_dependencies()`.")
  }

## End(Not run)


enblacar/SCpubr documentation built on Feb. 11, 2024, 4:15 a.m.