draw_plot: Draw a (sub)plot.

Description Usage Arguments Examples

View source: R/plot_grid.R View source: R/plot_grid.R

Description

Places a plot somewhere onto the drawing canvas. By default, coordinates run from 0 to 1, and the point (0, 0) is in the lower left corner of the canvas.

Places a plot somewhere onto the drawing canvas. By default, coordinates run from 0 to 1, and the point (0, 0) is in the lower left corner of the canvas.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
draw_plot(
  plot,
  x = 0,
  y = 0,
  width = 1,
  height = 1,
  scale = 1,
  hjust = 0,
  vjust = 0
)

draw_plot(
  plot,
  x = 0,
  y = 0,
  width = 1,
  height = 1,
  scale = 1,
  hjust = 0,
  vjust = 0
)

Arguments

plot

The plot to place. Can be a ggplot2 plot, an arbitrary grob or gtable, or a recorded base-R plot, as in [as_grob()].

x

The x location of the plot. (Left side if 'hjust = 0'.)

y

The y location of the plot. (Bottom side if 'vjust = 0'.)

width

Width of the plot.

height

Height of the plot.

scale

Scales the grob relative to the rectangle defined by 'x', 'y', 'width', 'height'. A setting of 'scale = 1' indicates no scaling.

hjust

Horizontal justification relative to x.

vjust

Vertical justification relative to y.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(ggplot2)

# make a plot
p <- ggplot(data.frame(x = 1:3, y = 1:3), aes(x, y)) +
    geom_point()
# draw into the top-right corner of a larger plot area
ggdraw() + draw_plot(p, .6, .6, .4, .4)
library(ggplot2)

# make a plot
p <- ggplot(data.frame(x = 1:3, y = 1:3), aes(x, y)) +
    geom_point()
# draw into the top-right corner of a larger plot area
ggdraw() + draw_plot(p, .6, .6, .4, .4)

Alik-V/heor documentation built on April 4, 2020, 9:38 p.m.