r - GGally::ggpairs 图不显示相关系数

标签 r ggplot2 ggally iris-dataset

我试图理解为什么在传递命令 ggpairs(iris, mapping=ggplot2::aes(colour = Species)) 时没有显示相关系数的图

console output

这是它的样子:
the plots displaying the correlation coefficient are not visible

如果我在绘图上执行检查元素,则 html 中的图像标签是:

<img id="img" width="100%" height="100%" style="display: inline;" src="http://127.0.0.1:27032/graphics/b7091da9-1a0a-4672-902e-7c844add4aa9.png">

我刚刚开始学习 R,因此这让我感到困惑。我觉得这是语言环境的问题,所以我尝试通过
Sys.setlocale("LC_ALL", 'en_US.UTF-8')
尽管再次调用库,但没有任何改变。

以下是一些细节:
R version 4.0.1 (2020-06-06) running on Arch Linux x86_64 5.6.15-arch1-1
> Sys.getlocale()
[1] "LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=C;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C"

如果我没有提供足够的数据,我深表歉意。如果是这样的话,我会更新这个。

使用 install.packages("GGally", type = 'source') 的输出更新帖子

> install.packages("GGally", type = 'source')
Installing package into ‘/home/mogad0n/R/x86_64-pc-linux-gnu-library/4.0’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/GGally_2.0.0.tar.gz'
Content type 'application/x-gzip' length 1393325 bytes (1.3 MB)
==================================================
downloaded 1.3 MB

* installing *source* package ‘GGally’ ...
** package ‘GGally’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (GGally)

The downloaded source packages are in
    ‘/tmp/RtmpvIM27v/downloaded_packages’

最佳答案

这显然与在 linux 中渲染等宽字体时发生冲突有关——冲突似乎与 tex 有关。 (参见 herehere )。
这是以前的样子:

library(GGally)
iris %>% 
  select(Sepal.Length:Petal.Width) %>% 
  ggpairs()
输出:
enter image description here
在我告诉它使用 sans 之后字体:
iris %>% 
  select(Sepal.Length:Petal.Width) %>% 
  ggpairs(upper = list(continuous = wrap("cor", family="sans")))
输出:
enter image description here
在 Ubuntu 20.04 和 R 版本 4.0.2 上为我工作

关于r - GGally::ggpairs 图不显示相关系数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62312493/

相关文章:

r - Rstudio 更有意义的窗口标题

r - 查找当前工作区中的所有函数

r - Tex Proof 环境未在 R Markdown 中定义,amsthm 未在生成的 Tex 文件中

r - R 中的平行坐标图 (ggparcoord)

c++ - 在 C++ 函数环境中删除输入 R 对象

r - 多个 gganimate 地 block 并排

r - 如何替换 `ggplot2::geom_histogram(` y = ..密度中的点对点表示法。 .`)`?

python - Plotnine:如何在绘制图形时删除 ggplot:(xxx) 类型烦人的文本输出

r - 是否可以拆分相关框以显示配对图中两种不同处理的相关值?

r - ggpairs 用白色填充直方图