In Plot: character encoding issue

plot

#1

Hello

I'm having problems with plots in rstudio server since I upgraded from Oracle Linux to RHEL7. When I execute plot(...), the characters are cryptic: usually some mathematic signs; even the numbers on the axis are cryptic. When I do the plots from inside of R, everything works fine; also when I'm saving the plot with

> png("~/cars.png")
> plot(cars)
> dev.off()

So it seems to be originating from rstudio somehow.

capabilities() and sessionInfo() give me the following output:

> capabilities()
       jpeg         png        tiff       tcltk         X11        aqua    http/ftp     sockets      libxml        fifo 
       TRUE        TRUE       FALSE        TRUE       FALSE       FALSE        TRUE        TRUE        TRUE        TRUE 
     cledit       iconv         NLS     profmem       cairo         ICU long.double     libcurl 
       TRUE        TRUE        TRUE       FALSE        TRUE        TRUE        TRUE        TRUE 
> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               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    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             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_2.1.0 shiny_1.0.5  

loaded via a namespace (and not attached):
 [1] colorspace_1.2-6 scales_0.3.0     plyr_1.8.3       R6_2.1.1         htmltools_0.3.6  tools_3.3.3      gtable_0.1.2    
 [8] yaml_2.1.13      Rcpp_0.12.10     grid_3.3.3       digest_0.6.8     xtable_1.7-4     httpuv_1.3.5     mime_0.4        
[15] munsell_0.4.2   

Can you guess where the problem is? Thanks very much.


#2

Could you offer an example of the plot with cryptic plots?


#3

Certainly:

The "cryptic" plot:
07

I can't post the second plot with the "regular" image, but when I create it directly from within the same R binary, the axis are labeled with dist and speed and the respective numbers.


#4

Here is actually the "regular" plot that I mentioned in the previous post:


#5

I didn't think that this might be of importance, but maybe it is after all: I didn't install R at the "standard" location but I compiled it myself and took my own path as prefix. R is not installed otherwise on the system.


#6

It could be worth checking if other graphics output has the same issue, e.g. pdf() output.

You could also reset your graphics device:


#7

Thanks for this tip. I have already tried resetting the device without a result.

But when I'm plotting to a PDF from within rstudio, it works like a charm. So it probably has to be something with the PNG routines. What does rstudio do differently when it invokes the plot() function as opposed to a regular plot() invocation outside of rstudio?


#8

One more thing, could you provide str(par())?
Perhaps a custom font is being set there, but it's not working as expected.


#9

This doesn't mean so much to me, but I hope it will help:

> str(par())
List of 72
 $ xlog     : logi FALSE
 $ ylog     : logi FALSE
 $ adj      : num 0.5
 $ ann      : logi TRUE
 $ ask      : logi FALSE
 $ bg       : chr "white"
 $ bty      : chr "o"
 $ cex      : num 1
 $ cex.axis : num 1
 $ cex.lab  : num 1
 $ cex.main : num 1.2
 $ cex.sub  : num 1
 $ cin      : num [1:2] 0.15 0.2
 $ col      : chr "black"
 $ col.axis : chr "black"
 $ col.lab  : chr "black"
 $ col.main : chr "black"
 $ col.sub  : chr "black"
 $ cra      : num [1:2] 14.4 19.2
 $ crt      : num 0
 $ csi      : num 0.2
 $ cxy      : num [1:2] 0.441 7.004
 $ din      : num [1:2] 8.95 5.48
 $ err      : int 0
 $ family   : chr ""
 $ fg       : chr "black"
 $ fig      : num [1:4] 0 1 0 1
 $ fin      : num [1:2] 8.95 5.48
 $ font     : int 1
 $ font.axis: int 1
 $ font.lab : int 1
 $ font.main: int 2
 $ font.sub : int 1
 $ lab      : int [1:3] 5 5 7
 $ las      : int 0
 $ lend     : chr "round"
 $ lheight  : num 1
 $ ljoin    : chr "round"
 $ lmitre   : num 10
 $ lty      : chr "solid"
 $ lwd      : num 1
 $ mai      : num [1:4] 1.02 0.82 0.82 0.42
 $ mar      : num [1:4] 5.1 4.1 4.1 2.1
 $ mex      : num 1
 $ mfcol    : int [1:2] 1 1
 $ mfg      : int [1:4] 1 1 1 1
 $ mfrow    : int [1:2] 1 1
 $ mgp      : num [1:3] 3 1 0
 $ mkh      : num 0.001
 $ new      : logi FALSE
 $ oma      : num [1:4] 0 0 0 0
 $ omd      : num [1:4] 0 1 0 1
 $ omi      : num [1:4] 0 0 0 0
 $ page     : logi TRUE
 $ pch      : int 1
 $ pin      : num [1:2] 7.71 3.64
 $ plt      : num [1:4] 0.0916 0.9531 0.1862 0.8503
 $ ps       : int 12
 $ pty      : chr "m"
 $ smo      : num 1
 $ srt      : num 0
 $ tck      : num NA
 $ tcl      : num -0.5
 $ usr      : num [1:4] 3.16 25.84 -2.72 124.72
 $ xaxp     : num [1:3] 5 25 4
 $ xaxs     : chr "r"
 $ xaxt     : chr "s"
 $ xpd      : logi FALSE
 $ yaxp     : num [1:3] 0 120 6
 $ yaxs     : chr "r"
 $ yaxt     : chr "s"
 $ ylbias   : num 0.2

#10

Have similar issue in RHEL7 with plot
figure

Locale on the machine
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

Locale -a output
C
en_US
en_US.iso88591
en_US.iso885915
en_US.utf8
POSIX

sessionInfo output
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server 7.3 (Maipo)

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

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

other attached packages:
[1] RevoUtilsMath_10.0.0

loaded via a namespace (and not attached):
[1] RevoUtils_10.0.

capabilities
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE TRUE FALSE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE FALSE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE TRUE TRUE TRUE TRUE TRUE


#11

Hi @jay_analytics and @Panidiomorphic,
Folks are still not sure what's causing the issue, but we've set-up an issue at the following link.
You can follow progress on this issue by commenting, or clicking subscribe under notifications on the github page.


#12

@Panidiomorphic @EconomiCurtis
Found what could be the issue. Rhel7 is missing one package "urw-fonts-2.4-16.el7.noarch"
After installing the package I was able to get the English labels.

yum install urw-fonts

image

Let me know if this helps.


#13

Thanks @jay_analytics, this solved my problem! No idea how it could be rendered for the other user, but now, it works for all users!