Possible Duplicate:
How to use an image as a point in ggplot?
Is it possible to have user defined pch (clip art or icon or other type of file) used as point in R base or ggplot or other graphical device.
For example:
set.seed(123)
mydt <- data.frame (x = rnorm(5, 5,2), y = rnorm (5,10,3), z = rnorm (5, 1,0.5))
Here size is proportional to z.
Using grid.raster
library(png)
flower <- readPNG("flower.png")
pushViewport(plotViewport(margins=c(5,5,5,5)))
grid.rect(gp = gpar(fill=NA))
pushViewport(plotViewport(margins=c(5,5,5,5),
xscale=extendrange(mydt$x),
yscale=extendrange(mydt$y)))
grid.raster(image=flower,x=mydt$x,y=mydt$y,width=mydt$z,
interpolate=FALSE,default.units = 'native')
grid.polyline(mydt$x,mydt$y,default.units='native')
upViewport(2)
For Base graphics look at the my.symbols
and ms.image
functions in the TeachingDemos package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With