Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with text in plot | Jupyter - R

I am trying to plot a simple scatterplot with some data using ggplot2 in R on Jupyter notebook installed through Anaconda. Following is the code I used:

ggplot(data = df1[1:1000,]) + geom_point(mapping = aes(x = val1, y = val2))

and the result is the following:

enter image description here

I am experiencing the same issue with normal plot function. For the command -

df <- data.frame(x=rnorm(10000),y=rnorm(10000))
plot(df[1:1000,1],df[1:1000,])

I am getting the following result:

enter image description here

Here's the sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: Amazon Linux Bare Metal release 2012.03

Matrix products: default
BLAS: /home/dmangla/sof/anaconda3/lib/R/lib/libRblas.so
LAPACK: /home/dmangla/sof/anaconda3/lib/R/lib/libRlapack.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] dplyr_0.7.4     purrr_0.2.3     readr_1.1.1     tidyr_0.7.1    
[5] tibble_1.3.4    ggplot2_2.2.1   tidyverse_1.1.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.13     cellranger_1.1.0 compiler_3.4.2   plyr_1.8.4      
 [5] bindr_0.1        forcats_0.2.0    tools_3.4.2      digest_0.6.12   
 [9] uuid_0.1-2       lubridate_1.6.0  gtable_0.2.0     jsonlite_1.5    
[13] evaluate_0.10.1  nlme_3.1-131     lattice_0.20-35  pkgconfig_2.0.1 
[17] rlang_0.1.2      psych_1.7.8      IRdisplay_0.4.4  IRkernel_0.8.9  
[21] parallel_3.4.2   haven_1.1.0      bindrcpp_0.2     xml2_1.1.1      
[25] httr_1.3.1       repr_0.12.0      stringr_1.2.0    hms_0.3         
[29] grid_3.4.2       glue_1.1.1       R6_2.2.2         readxl_1.0.0    
[33] foreign_0.8-69   pbdZMQ_0.2-6     modelr_0.1.1     reshape2_1.4.2  
[37] magrittr_1.5     scales_0.5.0     rvest_0.3.2      assertthat_0.2.0
[41] mnormt_1.5-5     colorspace_1.3-2 labeling_0.3     stringi_1.1.5   
[45] lazyeval_0.2.0   munsell_0.4.3    broom_0.4.2      crayon_1.3.4    

I've tried reinstalling the packages but the problem still persists. Kindly tell if anyone knows what's the problem here and how to fix it.

Thanks to all.

like image 212
Divya Manglam Avatar asked Nov 19 '25 16:11

Divya Manglam


1 Answers

This is an issue with Anaconda not installing fonts by default. The solution is to install some fonts:

conda install -c anaconda fonts-anaconda

like image 85
JD Long Avatar answered Nov 21 '25 05:11

JD Long