Displaying ggplot2 graphs from R in Jupyter

前端 未结 2 1627
谎友^
谎友^ 2020-12-30 13:13

When I create a plot in Jupyter using the ggplot2 R package, I get a link to the chart that says \"View PDF\" instead of the chart being presented inline.

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-30 14:05

    You can show the graphs inline with this option.

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

    You can also produce pdf files as you would regularly in R, e.g.

    pdf("test.pdf")
    ggplot(data.frame(a=rnorm(100,1,10)),aes(a))+geom_histogram()
    dev.off()
    

提交回复
热议问题