geom_line_with_image: Line Plot Using Images

Description Usage Arguments Note Examples

Description

This function allows you to draw a simple line plot of y vs. x, using one or two images

Usage

1
2
3
4
geom_line_with_image(bottomImg = NULL, topImg = NULL, mapping = NULL,
  data = NULL, stat = "identity", position = "identity", na.rm = FALSE,
  show.legend = NA, inherit.aes = TRUE, bgColor = "white",
  lineColor = 1, lineWidth = 1, lineType = "solid", ...)

Arguments

bottomImg

The image "below" the line. This should be an image object as obtained by png::readPNG, jpeg::readJPEG, magick::image_read etc. You must specify at least this image.

topImg

The image "above" the line.

bgColor

Background color above the line in case you don't specify topImg, defaults to white.

lineColor

Line color as accepted by R in the col parameter, defaults to black.

lineWidth

Line width as accepted by R in the lwd parameter, defaults to 1.

lineType

Line type as accepted by R in the lty parameter, defaults to "solid".

...

Other standard ggplot2 parameters such as mapping, data, stat etc.

Note

By default geom_line_with_image will not add padding in the x and y axes. This default behavior of ggplot2 does not make sense when it comes to plotting with images. You can however override this by adding + xlim(c(0, 100)). Make sure the result is meaningful though.

Examples

1
2
3
4
5
6
annapurna <- png::readPNG(system.file("extdata", "annapurna.png", package = "ggwithimages"))
sky <- png::readPNG(system.file("extdata", "sky.png", package = "ggwithimages"))
kathmandu_hourly_aqi <- readr::read_csv(system.file("extdata", "kathmandu_hourly_aqi.csv", package = "ggwithimages"))
library(ggplot2)
ggplot(kathmandu_hourly_aqi, aes(hour, aqi)) +
  geom_line_with_image(annapurna, sky)

gsimchoni/ggwithimages documentation built on May 21, 2019, 3:09 a.m.