试图使用plotly
在R
中完成我的第一步。将ggplot2对象保存为gglotlot并保存到Linux中的磁盘
我想将我的ggplot2
对象转换为ggplotly
对象,然后在Linux
平台上将它保存为html
。我希望能够从命令行调用此R代码并将其作为脚本执行,而不是通过RStudio
运行它。
我认为这会做(from plotly
's manual):
require(ggplot2)
require(plotly)
ggiris <- qplot(Petal.Width, Sepal.Length, data = iris, color = Species)
ggiris.ly <- ggplotly(ggiris)
htmlwidgets::saveWidget(ggiris.ly,"ggiris.html")
但ggplotly(ggiris)
抛出这个错误:
Error in .External2(C_X11, paste("png::", filename, sep = ""), g$width, :
unable to start device PNG
In addition: Warning message:
In dev_fun(tmpPlotFile, width = deviceWidth, height = deviceHeight) :
unable to open connection to X11 display ''
我再装XQuartz
能够ssh -X -Y
从我Mac
我linux
系统。
ggiris.ly <- ggplotly(ggiris)
打开R Graphics
设备,但随后
htmlwidgets::saveWidget(ggiris.ly,"~/Downloads/ggiris.html")
抛出这个错误:
Error in htmlwidgets::saveWidget(ggiris.ly, "~/Downloads/ggiris.html") :
Saving a widget with selfcontained = TRUE requires pandoc. For details see:
https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md
任何想法?
BTW, 我使用plotly_4.5.6
和ggplot2_2.2.1
谢谢。我注意到并修复了它,但错误与此无关。 – user1701545
固定。再次感谢。 – user1701545
与win7上的相同版本可以正常工作 – HubertL