1

The code is shown below. I installed R using Conda (I'm working on a cluster and don't have sudo). Everything works normally except the text. I would appreciate it if someone can let me know how to fix this. Edit: I tried the solution offered by R Draws Plots with Rectangles Instead of Text, which is to install mscorefonts for the conda environment. But this doesn't fix the issue. If you carefully compare the plot I attached and the plot attached in the link, they are actually very different. In my plot, all the boxes have numbers in them, whereas in the plot in the link, all the boxes are blank.

$ conda install -c conda-forge r-base=3.6.1
$ conda install -c conda-forge mscorefonts
$ R --vanilla
# inside R:
> install.packages("ggplot2")
> library(ggplot2)
> df <- data.frame(x = 1:3, y = 2:4)
> ggplot(df, aes(x=x, y=y)) + geom_point() + ggsave("~/test/test_square2.png")
> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Ubuntu 16.04 LTS

Matrix products: default
BLAS/LAPACK: /bar/cfan/anaconda2/envs/ren/lib/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.3.3

loaded via a namespace (and not attached):
 [1] digest_0.6.27    withr_2.4.1      crayon_1.4.0     grid_3.6.1      
 [5] R6_2.5.0         lifecycle_0.2.0  gtable_0.3.0     magrittr_2.0.1  
 [9] scales_1.1.1     pillar_1.4.7     rlang_0.4.10     farver_2.0.3    
[13] vctrs_0.3.6      ellipsis_0.3.1   labeling_0.4.2   tools_3.6.1     
[17] glue_1.4.2       munsell_0.5.0    compiler_3.6.1   pkgconfig_2.0.3 
[21] colorspace_2.0-0 tibble_3.0.6    
> 

The plot is attached. As you can see, all text became random squares. enter image description here

Final edit: this issue is solved by the solution offered in here: ggplot2 issue: graph text shown with weird unicode blocks

Jerry Fan
  • 105
  • 6
  • Possibly related: https://stackoverflow.com/questions/65898007/ggplot2-issue-graph-text-shown-with-weird-unicode-blocks – teunbrand Feb 09 '21 at 16:40
  • and also related (just to directly link to the thread) https://stackoverflow.com/questions/65904805/ggplot2-issue-with-default-font-size-base-family – tjebo Feb 09 '21 at 17:49
  • 1
    @teunbrand I can confirm that the solution in https://stackoverflow.com/questions/65898007/ggplot2-issue-graph-text-shown-with-weird-unicode-blocks fixed my issue as well. Thank you so much for pointing me towards it! – Jerry Fan Feb 09 '21 at 19:06

0 Answers0