## Using an image as the axis text in R plot

There were plenty of good suggestions on this page . But the one that worked for me was in one of the comments. Use the package “tikzDevice” and you can add the awesomeness of Latex to the plotting prowess of R. All you have to do is to construct a Latex directive in R, and use it in the R plot commands, wherever you want. tikzDevice will create a tex document for you. Compile it and you are ready to go.

Example

library(tikzDevice)

library(ggplot2)

axislabels=c()

for (i in seq(1,3)) { fname=paste(“placeholder”,i,sep=””) #img is of course present in the wd. al=paste(“\\includegraphics[scale=0.05]{“,fname,”}”,sep=””) axislabels=c(axislabels,al) }

dat <- data.frame(cond = rep(c(“Good”, “Bad”), each=10),xvar = 1:10 + rnorm(10,sd=1), yvar = 1:10 + rnorm(10,sd=10))

p=qplot(1:3,1:3) +  scale_x_discrete(limits=c(1,2,3),labels=axislabels) tikz(“annotated.tex”,standAlone=T)

print(p)

dev.off()