0
我无法将在R sweave中通过plotly创建的图表转换为Pdf。但是可以创建其他图表。是否还有其他附加代码需要添加到绘图图表中?无法编译从R sweave到Plotly的图表
下面是一个例子
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<echo = FALSE>>=
C1<-c("A","B","C")
C2<-c(10,20,30)
Df<-data.frame(C1,C2)
@
\begin {figure}
<<echo = FALSE, fig = TRUE>>=
suppressWarnings (library (plotly))
plot_ly(Df, x = ~C1, y = ~C2, type = "bar")%>% layout(title = "ABC")
@
\caption {PlotlyChart}
\end {figure}
Normal Chart
\begin {figure}
<<echo = FALSE, fig = TRUE>>=
barplot(Df[ ,2], names.arg = Df[ ,1])
@
\caption {Normal_Chart}
\end {figure}
\end{document}
当我尝试R中正常的箱形图,它的工作原理。只有当我添加Plotly图表,我得到一个错误消息
Running pdflatex on ABC.tex...failed
Error running /Library/TeX/texbin/pdflatex (exit code 1)
我是新至R sweave和乳胶,所以任何帮助表示赞赏。谢谢!
非常有趣的解决方案。另外值得注意的是,'phantomjs'可以作为独立的终端工具使用,如果你想简单地生成Plotly HTML输出的静态图像,这可能会很有用。 http://phantomjs.org/screen-capture.html – user5359531
@HubertL - 像魔术般运作。感谢您的解决方案。 – Jessie