Recently I came across a problem in R (3.2.3 and 3.2.4).
When I type in R:
plot(1:5, 1:5)
X11 font -adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*, face 1 at size 12 could not be loaded
and I missed all the x-axis and y-axis labels.
My R sessionInfo() is
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Red Hat Enterprise Linux Server release 6.6 (Santiago)
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
I tried
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
and tried font settings:
X11Fonts()
$serif
[1] “-*-times-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$sans
[1] “-*-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$mono
[1] “-*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$Times
[1] “-adobe-times-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$Helvetica
[1] “-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$CyrTimes
[1] “-cronyx-times-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$CyrHelvetica
[1] “-cronyx-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$Arial
[1] “-monotype-arial-%s-%s-*-*-%d-*-*-*-*-*-*-*”
$Mincho
[1] “-*-mincho-%s-%s-*-*-%d-*-*-*-*-*-*-*”
capabilities()
jpeg png tiff tcltk X11 aqua
TRUE TRUE TRUE TRUE TRUE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE FALSE TRUE TRUE TRUE FALSE
My X11 and cairo are both TRUE. And R supposes to used cairo as default.
X11.options: type
character string, one of “Xlib” (the only type prior to R 2.7.0) or “cairo” or “nbcairo”. The latter two will only be available if the system was compiled with support for cairo. Default “cairo” where available, otherwise “Xlib”.
However, the R (my own install version rather than the HPC system installed version(3.1.3)) use Xlib as default.
X11.options()
$display
[1] “”
$width
[1] NA
$height
[1] NA
$pointsize
[1] 12
$bg
[1] “transparent”
$canvas
[1] “white”
$gamma
[1] 1
$colortype
[1] “true”
$maxcubesize
[1] 256
$fonts
[1] “-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*”
[2] “-adobe-symbol-medium-r-*-*-%d-*-*-*-*-*-*-*”
$family
[1] “sans”
$xpos
[1] NA
$ypos
[1] NA
$title
[1] “”
$type
[1] “Xlib”
$antialias
[1] “default”
You can see the X11() type is Xlib, which causes this problem.
When I set X11(type = “cairo”)
plot(1:4, 1:4)
the problem solved!
Finally, to make my life easier, I set these codes to .Rprofile
# default X11() setting
setHook(packageEvent(“grDevices”, “onLoad”),
function(…) grDevices::X11.options(width = 8, height = 8, xpos = 0,
pointsize = 10, type = “cairo”))