Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set cairo as default backend for x11() in R?

Tags:

r

ggplot2

cairo

I am using ggplot2 on ubuntu 12.04. By default my x11 type is set to Xlib. So when I use a smoother in qplot, I get an error like:

"semi-transparency is not supported on this device: reported only once per page".

However, if I call x11(type="cairo"), everything works fine.

How do I get cairo as the default backend for x11?

like image 939
signalseeker Avatar asked May 27 '12 20:05

signalseeker


2 Answers

To make this permanent, you could add the following lines to your ~/.Rprofile file:

setHook(packageEvent("grDevices", "onLoad"),
function(...) grDevices::X11.options(type='cairo'))
options(device='x11')
like image 123
Cyrus Avatar answered Nov 09 '22 21:11

Cyrus


Define another function 'x11' which sets the proper type:

x11 = function (...) grDevices::x11(...,type='cairo')
like image 20
Matthew Lundberg Avatar answered Nov 09 '22 23:11

Matthew Lundberg