Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R not producing a figure in jupyter (IPython notebook)

I am very excited about using python and R together and tried using R in Jupyter (ipython notebbok), however, I could not generate figures in the R kernel.

The error message shown below is displayed when I try to plot figures. I highly appreciate your help.

I am using Anaconda and windows 8.

x<-1:10
plot(x)

Error in png(tf, width, height, "in", pointsize, bg, res, type = "cairo", : unable to load winCairo.dll: was it built?

Error in jpeg(tf, width, height, "in", pointsize, quality, bg, res, type = "cairo", : unable to load winCairo.dll: was it built?

The following is displayed in the Anaconda command prompt:

Unable to load 'C:/Users/aa/Anaconda/R/library/grDevices/libs/x64/winCairo.dll'

like image 317
Fisseha Berhane Avatar asked May 24 '15 06:05

Fisseha Berhane


1 Answers

I found a solution from the post on this group.

Solution I did:

I had the most release of R (R 3.2.0) and following the discussion in the above link, I installed R 3.1.3 and copied winCairo.dll from C:\Program Files\R\R-3.1.3\library\grDevices\libs\x64 to C:\Anaconda\R\library\grDevices\libs\x64.

Copying winCairo.dll from R 3.2.0 does not work for my case.

With this, it plots a figure but with an error message that says "Error in replayPlot(obj): invalid graphics state"

Then, thanks to this link, I added 'options(jupyter.plot_mimetypes = 'image/png')' and it works fine.

enter image description here

options(jupyter.plot_mimetypes = 'image/png')

x=1:10

plot(x)

enter image description here

like image 147
Fisseha Berhane Avatar answered Sep 21 '22 06:09

Fisseha Berhane