image_ggplot: Image to ggplot

Description Usage Arguments Examples

View source: R/ggplot2.R

Description

Converts image to raster using image_raster() and then plots it with ggplot2 geom_raster. See examples for other ways to use magick images in ggplot2.

Usage

1

Arguments

image

magick image object returned by image_read() or image_graph()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# Plot with base R
plot()

# Plot image with ggplot2
library(ggplot2)
myplot <- image_ggplot()
myplot + ggtitle("Test plot")

# Or add to plot as annotation
image <- image_fill(, 'none')
raster <- as.raster(image)
myplot <- qplot(mpg, wt, data = mtcars)
myplot + annotation_raster(raster, 25, 35, 3, 5)

# Or overplot image using grid
library(grid)
qplot(speed, dist, data = cars, geom = c("point", "smooth"))
grid.raster(image)

ropensci/magick documentation built on Jan. 15, 2019, 3:27 a.m.