4

I am trying to understand why the plot with the correlation coefficient is not showing while passing the command ggpairs(iris, mapping=ggplot2::aes(colour = Species))

console output

Here is what it looks like: the plots displaying the correlation coefficient are not visible

if i perform inspect element on the plot, the image tag in the html is:

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

I have just started learning R and hence this confounded me. I felt like it was an issue with the locale so i tried experimenting by

Sys.setlocale("LC_ALL", 'en_US.UTF-8')

By nothing changed despite calling the libraries again.

Here are some details:

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"

I apologize if I haven't provided enough data. I shall update this if that is the case.

Updating the post with the output from 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’
mogad0n
  • 41
  • 5
  • I have removed the packages and restarted R and performed `install.packages("GGally", type = 'source')` along with the same for `ggplot2` it still has the the same issue. I didn't see any mention of `package encoding: UTF-8`. I am updating my post with the output of the installation command for `GGally`. – mogad0n Jun 11 '20 at 10:20
  • Hi @mogad0n. Unfortunately I can't reproduce your problem. Everything works fine on my (Windows) machine. From the picture you posted I looks like a font problem as the text is not displayed correctly. To check wether this is related to GGAlly or perhaps a more general problem test e.g. `ggplot(data.frame(label = "corr:", corr = 1)) + geom_text(aes(x = factor(1), y = factor(1), label = paste(label, corr), color = label), family = "mono") +` guides(color = FALSE) + theme_void()` which gives you a simple plot which should display `corr: 1` using the mono font. – stefan Jun 11 '20 at 12:07
  • @stefan it does not display it. So it is likely a font problem? if yes how would i fix this. I looked into it a bit I found references to packages like `extrafont` and `showtext`. But i dont want to do random things without some sort of reasoning – mogad0n Jun 11 '20 at 12:33
  • Hi @mogad0n. That's what I guessed. (; Hm. Unfortunately I'm afraid that I can't help you on that. What I would try is to restart R (always a good idea). Otherwise post a new question on the specific font problem, e.g. `Fonts not displayed in ggplot2` – stefan Jun 11 '20 at 12:38

1 Answers1

3

This apparently has to do with a conlfict when rendering monospace fonts in linux -- the conflict appears to have something to do with tex (see here and here).
This is what it looked like before:

library(GGally)
iris %>% 
  select(Sepal.Length:Petal.Width) %>% 
  ggpairs()

output: enter image description here

and after I told it to use a sans font:

iris %>% 
  select(Sepal.Length:Petal.Width) %>% 
  ggpairs(upper = list(continuous = wrap("cor", family="sans")))

output: enter image description here

worked for me on Ubuntu 20.04 and R version 4.0.2

brian avery
  • 403
  • 2
  • 8