Description Usage Arguments Note Examples
This function allows you to draw a simple histogram of a single variable, using one or two images
1 2 3 4 5 |
bottomImg |
The image "inside" the histogram. This should be an image object
as obtained by |
topImg |
The image "outside" the histogram. |
bgColor |
Background color outside the histogram in case you don't specify
|
lineColor |
Line color as accepted by R in the |
lineWidth |
Line width as accepted by R in the |
lineType |
Line type as accepted by R in the |
breaks |
See the |
freq |
See the |
... |
Other standard ggplot2 parameters such as mapping, data, stat etc. |
By default geom_hist_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.
1 2 3 4 5 6 7 | nyc <- png::readPNG(system.file("extdata", "nyc.png", package = "ggwithimages"))
night_sky <- png::readPNG(system.file("extdata", "night_sky.png", package = "ggwithimages"))
nyc_accidents <- readr::read_csv(system.file("extdata", "nyc_accidents.csv", package = "ggwithimages"))
library(ggplot2)
ggplot(nyc_accidents, aes(n_accidents)) +
geom_hist_with_image(nyc, night_sky) +
ylim(c(0, 700))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.