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.





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)


This entry was posted in Notes and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s