使用R时无法在Jupyter笔记本中显示HTML小部件(使用python时有效)。例如,在Jupyter R笔记本中没有任何绘图图表。对此有什么解决方案吗?
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat)
代码执行但不显示图表
答案 0 :(得分:3)
您需要拨打embed_notebook
电话(请参阅示例here)。
所以将代码更改为:
library(plotly)
set.seed(100)
d <- diamonds[sample(nrow(diamonds), 1000), ]
myPlot <- plot_ly(d, x = carat, y = price, text = paste("Clarity: ", clarity),
mode = "markers", color = carat, size = carat)
embed_notebook(myPlot)