ggsave_mpinl_poster_portrait: Saving helper functions

Description Usage Arguments Examples

View source: R/save_helpers.R

Description

These functions are wrappers around the ggplot2 convenience function ggsave, for saving a plot. They default to saving the last plot that you displayed. The width is in each case predefined to have the correct width for the MPI poster templates. Do adjust the height though! There are versions for portrait and landscape poster templates, since these have different column widths.

Usage

1
2
3
4
5
6
7
8
plot + theme_mpinl_poster()
ggsave_mpinl_poster_portrait("posterfigure_1.pdf") # The default height is
ggsave_mpinl_poster_portrait("posterfigure_2.pdf",height = 200, units = "mm")
ggsave_mpinl_poster_landscape("outputfilename_landscape.pdf")

ggsave_mpinl_poster_landscape(filename, plot = ggplot2::last_plot(),
  device = NULL, path = NULL, scale = 1, width = NA, height = NA,
  units = c("in", "cm", "mm"), dpi = 500, limitsize = TRUE, ...)

Arguments

filename

File name to create on disk.

plot

Plot to save, defaults to last plot displayed.

device

Device to use. Can be either be a device function (e.g. png()), or one of "eps", "ps", "tex" (pictex), "pdf", "jpeg", "tiff", "png", "bmp", "svg" or "wmf" (windows only).

path

Path to save plot to (combined with filename).

scale

Multiplicative scaling factor.

width

Plot size in units ("in", "cm", or "mm"). If not supplied, uses the size of current graphics device.

height

Plot size in units ("in", "cm", or "mm"). If not supplied, uses the size of current graphics device.

units

Plot size in units ("in", "cm", or "mm"). If not supplied, uses the size of current graphics device.

dpi

Plot resolution. Also accepts a string input: "retina" (320), "print" (300), or "screen" (72). Applies only to raster output types.

limitsize

When TRUE (the default), ggsave will not save images larger than 50x50 inches, to prevent the common error of specifying dimensions in pixels.

...

Other arguments passed on to the graphics device function, as specified by device.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
mtcars2 <- within(mtcars, {
vs <- factor(vs, labels = c("V-shaped", "Straight"))
am <- factor(am, labels = c("Automatic", "Manual"))
cyl  <- factor(cyl)
gear <- factor(gear)
})

library(ggplot2)
library(mpinltheme)

p1 <- ggplot(mtcars2) +
  geom_point(aes(x = wt, y = mpg, colour = gear)) +
    labs(title = "Fuel economy declines as weight increases",
         subtitle = "(1973-74)",
         x = "Weight (1000 lbs)",
         y = "Fuel economy (mpg)",
         colour = "Gears")

p1 + scale_colour_discrete_mpinl() + theme_mpinl_poster()
ggsave_mpinl_poster_portrait("outputfilename.pdf")

joerodd/mpinltheme documentation built on May 23, 2019, 1:59 a.m.