I'm trying to include a graph and a local PNG side by side in a knitr LaTeX document, but the PNG ends up on top of the graph. Take this .Rnw example:
\documentclass{article}
\begin{document}
<<makeplot, echo=FALSE, message=FALSE, include=FALSE>>=
opts_chunk$set(echo=FALSE, warning = FALSE, message = FALSE, cache = FALSE, error = FALSE)
library("ggplot2")
library("png")
library("grid")
data = data.frame(x = c(1:5), y = c(1:5))
myplot = ggplot(data = data) +
geom_point(aes(x = x, y = y))
@
<<these_plots, echo = FALSE, fig.height = 3, fig.width = 8, results = "asis", fig.show = "hold">>==
par(mar=c(4,4,.1,.1),cex.lab=.95,cex.axis=.9,mgp=c(2,.7,0),tcl=-.3)
myplot
grid.raster(readPNG(system.file("img", "Rlogo.png", package="png")), height = .3, width = .3)
@
Which generates this:
How can I make them side by side? I've also tried the multiplot()
function from here but the PNG wouldn't budge from the row above the graph, even when cols was specified as 2.
multiplot(myplot,
grid.raster(readPNG(system.file("img", "Rlogo.png", package="png")), height = .3, width = .3), cols = 2)