2

使用 ggplot2 和 pgfsweave(+Lyx) 时遇到了问题。当我在 R 中运行我的代码时,我得到了一个带有彩色/阴影图块的漂亮图,并且这些图块在通过 pgfsweave 运行时不会出现。请注意,使用 ggplot2 的其他图表对我有用(使用 geom_line)

有什么我想念的吗?

这是一个应该是可重现的示例:

R代码(导致彩色方块):

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

在这里它是一个 pgfsweave/lyx 块(并导致一个没有填充正方形的图表)

\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}

编辑:添加我的设置详细信息,因为该示例对其他人来说运行良好。- Lyx 是 2.0 - pgfSweave 是 1.2.1 - 操作系统是 Windows 7 - R 是 2-13.1

4

0 回答 0