I've tried to follow the answer's given already for adding images to plots, but they do not work when using coord_polar()
# install.packages("RCurl", dependencies = TRUE)
library(RCurl)
myurl <- "http://vignette2.wikia.nocookie.net/micronations/images/5/50/German_flag.png"
# install.packages("png", dependencies = TRUE)
library(png)
img <- readPNG(getURLContent(myurl))
# install.packages("ggplot2", dependencies = TRUE)
library(ggplot2)
ger <- grid::rasterGrob(img, interpolate=TRUE)
## works, adds the image to the plot
ggplot(mtcars, aes(x=mpg, y= cyl)) + geom_line() + annotation_custom(ger, 10, 15, 5)
## doesn't work
ggplot(mtcars, aes(x=mpg, y= cyl)) + geom_line() + annotation_custom(ger) + coord_polar()
> Error: annotation_custom only works with Cartesian coordinates
Ideally I'd like to be able to position the flag image within the center of the polar plot, and another image along the y-axis.
Is there anyway to add the image? It can be as-is, no transformation required.
I'm using ggplot2
version 2.0
ex
?). – Cauterycowplot
package might do what you need. – Akim