考虑以下两张图片。两者使用相同的代码,但呈现方式不同。第一个是出现在 RStudio 的“绘图”面板中的图像,第二个是出现在相应的 knitted HTML 文档中的图像。
观察“低于 0.1”标签的“图例”中的差异。为什么knitr 以不同的方式呈现文档,并用图例标签中绘图的灰色背景色替换黑色? (我意识到没有低于 0.1 的值,因此它们“丢失”,但我特别希望即使这些值丢失,图例标签仍然出现。)
https://github.com/a-s-russo/austemp 特别是,请参阅 weather_graphs.html
分支中的
pipeline
文件,该文件生成上面的knitr 图像。上面的 RStudio 图像可以通过按照 main
分支页面上的说明安装软件包来重现(或参见下面的前三行代码)。这两个图像都是使用以下调用 plot_temperatures()
创建的:> devtools::install_github("a-s-russo/austemp")
> library(austemp)
> data('Sydney')
> plot_temperatures(data = Sydney, season = 'winter')
(注意:忽略图像大小差异。这只是因为我为了创建这个问题而调整大小并保存它们的方式。)
sessionInfo()
添加到两个输出(RStudio 和 RMarkdown),因为我无法在我的系统 (macOS) 上重现该问题:
# devtools::install_github("a-s-russo/austemp")
library(austemp)
data('Sydney')
plot_temperatures(data = Sydney, season = 'winter')
#> The ending year has been adjusted to match the data availability
sessionInfo()
#> R version 4.3.0 (2023-04-21)
#> Platform: x86_64-apple-darwin20 (64-bit)
#> Running under: macOS Ventura 13.6.5
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> time zone: Australia/Melbourne
#> tzcode source: internal
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] austemp_0.1
#>
#> loaded via a namespace (and not attached):
#> [1] styler_1.10.2 utf8_1.2.4 generics_0.1.3 tidyr_1.3.1
#> [5] xml2_1.3.6 lattice_0.22-5 stringi_1.8.3 hms_1.1.3
#> [9] digest_0.6.34 magrittr_2.0.3 evaluate_0.23 grid_4.3.0
#> [13] timechange_0.3.0 padr_0.6.2 fastmap_1.1.1 R.oo_1.25.0
#> [17] R.cache_0.16.0 R.utils_2.12.3 httr_1.4.7 rvest_1.0.4
#> [21] purrr_1.0.2 fansi_1.0.6 scales_1.3.0 cli_3.6.2
#> [25] rlang_1.1.3 R.methodsS3_1.8.2 munsell_0.5.0 reprex_2.1.0
#> [29] withr_3.0.0 yaml_2.3.8 tools_4.3.0 tzdb_0.4.0
#> [33] dplyr_1.1.4 colorspace_2.1-0 ggplot2_3.5.0 vctrs_0.6.5
#> [37] R6_2.5.1 zoo_1.8-12 lifecycle_1.0.4 lubridate_1.9.3
#> [41] stringr_1.5.1 fs_1.6.3 pkgconfig_2.0.3 pillar_1.9.0
#> [45] gtable_0.3.4 glue_1.7.0 Rcpp_1.0.12 xfun_0.41
#> [49] tibble_3.2.1 tidyselect_1.2.1 rstudioapi_0.15.0 knitr_1.45
#> [53] farver_2.1.1 htmltools_0.5.7 rmarkdown_2.25 readr_2.1.5
#> [57] compiler_4.3.0