ggplot没有出现在html输出中

时间:2018-08-03 11:19:55

标签: r ggplot2 gridextra rhtml

我正在尝试打印保存在列表“ plotList”中的ggplot图形,并将其作为html输出,但是当我执行代码并打开html链接时,除绘图外,所有我做HTML的表都在这里! >

这是R代码中用于制作html绘图的部分:

x1  x2  x3
q   w   e
r   e   q

编辑: 我意识到,由于我使用grid.arrang来收集情节,因此情况应该有所不同。现在,我使用rangingGrobe能够使用ggsave保存绘图。

这是情节信息:

PlotPath <- paste0(htmlOutput, "/", thisnode, ".svg")
  svg(PlotPath)
  plot(plotList[[thisnode]])
  makeFootnote()
  dev.off()
  imgline <- sprintf("<iframe src= %s width='1000' height='450' align='middle' style='border:none'></iframe>", plotList[[thisnode]])
  R2HTML::HTML(imgline, file = PlotPath)

所以我对代码做了一些更改:

class(plotList$node1)
[1] "gtable" "gTree"  "grob"   "gDesc"

我得到了错误:

PlotPath <- paste0(htmlOutput, "/", thisKPI, ".svg")
  svg(PlotPath)
  ggplot2::ggsave(PlotPath, plotList[[thisnode]])
  imgline <- sprintf("<iframe src= %s width='1000' height='450' align='middle' style='border:none'></iframe>", plotList[[thisnode]])
  R2HTML::HTML(imgline, file = PlotPath)

任何人都可以帮助我,非常感谢!

0 个答案:

没有答案
相关问题