简体   繁体   中英

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'

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.

在此输入图像描述

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

x=1:10

plot(x)

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM