开发者

Making pgfsweave work with all ggplot2 plots

Have run into a problem using ggplot2 and pgfsweave(+Lyx). When I run my code in R, I get a nice plot with coloured/shaded tiles, and those tiles do not appear when running via pgfsweave. Note that other graphs using ggplot2 are working for me (using geom_l开发者_运维百科ine)

Is there anything I am missing?

Here is a what should be a reproducible example:

R code (which results in coloured squares):

library(ggplot2)
data(iris)

corr.Matrix <- cor(iris[1:4])

corr.Melted <- melt(corr.Matrix)
names(corr.Melted) <- c("Var1", "Var2", "Correlation")

corr.Plot <- ggplot(corr.Melted, aes(Var1, Var2, fill=Correlation)) + 
  geom_tile()

# view plot
corr.Plot

And here it is in a pgfsweave/lyx chunk (and results in a graph with no filled in squares)

\begin{center}
<<CorrelationVis,fig=TRUE,echo=FALSE>>=
  library(ggplot2)
  data(iris)

  corr.Matrix <- cor(iris[1:4])

  corr.Melted <- melt(corr.Matrix)
  names(corr.Melted) <- c("Var1", "Var2", "Correlation")

  corr.Plot <- ggplot(corr.Melted, aes(Var1, Var2, fill=Correlation)) + 
    geom_tile()

  # view plot
  print(corr.Plot)
@
\end{center}

EDIT: Adding my setup details, as it appears the example runs fine for others. - Lyx is 2.0 - pgfSweave is 1.2.1 - OS is Windows 7 - R is 2-13.1

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜