【问题标题】:Why is knitr producing blurred images in pdfs?为什么 knitr 在 pdf 中生成模糊图像?
【发布时间】:2017-10-31 11:06:03
【问题描述】:

好吧,这让我发疯了。这是一个 MWE:

\documentclass{article}

\begin{document}

<<simulations, fig.cap = "Simulation results. $b$ = benefit of being helped. $n$ = group size.", fig.align = "center", fig.width = 6, fig.height = 4,  out.width='6in', out.height='4in', dev = 'quartz_pdf', dev.args = list(antialias=FALSE), echo=FALSE>>=


tmp <- structure(list(memory = c(30, 30, 30, 30, 30, 30, 30, 30, 30, 
30, 30, 30), G = c(10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 
10), b = c(12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14), gsize = c(12, 
14, 16, 18, 20, 22, 24, 26, 28, 30, 12, 14), GR_wins = c(0.2, 
0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0.2, 0), Condition = c("m = t = 30, G = 10", 
"m = t = 30, G = 10", "m = t = 30, G = 10", "m = t = 30, G = 10", 
"m = t = 30, G = 10", "m = t = 30, G = 10", "m = t = 30, G = 10", 
"m = t = 30, G = 10", "m = t = 30, G = 10", "m = t = 30, G = 10", 
"m = t = 30, G = 10", "m = t = 30, G = 10"), grwc = structure(c(2L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L), .Label = c("[0,0.1]", 
"(0.1,0.2]", "(0.2,0.3]", "(0.3,0.4]", "(0.4,0.5]", "(0.5,0.6]", 
"(0.6,0.7]", "(0.7,0.8]", "(0.8,0.9]", "(0.9,1]"), class = "factor")), .Names = c("memory", 
"G", "b", "gsize", "GR_wins", "Condition", "grwc"), row.names = c(NA, 
-12L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = c("memory", 
"G", "b"), drop = TRUE, indices = list(0:9, 10:11), group_sizes = c(10L, 
2L), biggest_group_size = 10L, labels = structure(list(memory = c(30, 
30), G = c(10, 10), b = c(12, 14)), row.names = c(NA, -2L), class = "data.frame", vars = c("memory", 
"G", "b"), drop = TRUE, .Names = c("memory", "G", "b")))

library(ggplot2)

ggplot(tmp, aes(gsize, b, fill = grwc)) + geom_raster()

@


\end{document}

当我在命令行中运行代码块时,我得到如下图片:

但是当我使用 xelatex 编译它时,通过点击 RStudio 中的 knit 按钮,我得到了这个可怕的东西:

我尝试将 dev.args 中的 out.width、fig.width、antialiasing 与石英驱动程序、不同的驱动程序混为一谈……任何人都可以帮忙吗?

【问题讨论】:

    标签: r latex knitr r-markdown


    【解决方案1】:

    好的,我修复了它,但不确定如何修复,只需进入figure 子目录并删除正在缓存的相关数字即可。之后,使用dev="png" 给了我一个OK的结果。

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 2014-05-13
      • 2019-05-22
      • 2021-08-26
      • 1970-01-01
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多