在jupyterlab / jupyternotebooks中运行highcharter

时间:2018-04-18 13:01:11

标签: html r-highcharter jupyter-lab

我正在尝试在jupyterlab中呈现一些highcharter图表

data(diamonds, economics_long, mpg, package = "ggplot2")
library(dplyr)
library(highcharter)
hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class))

要让plotlywrapper正常工作,您需要安装扩展程序。我可以想象必须为highcharter建立类似的东西?

错误消息:

HTML widgets cannot be represented in plain text (need html)

1 个答案:

答案 0 :(得分:0)

https://blog.ouseful.info/2018/04/26/r-htmlwidgets-in-jupyter-notebooks/

data(diamonds, economics_long, mpg, package = "ggplot2")
library(dplyr)
library(highcharter)
x=hchart(mpg, "scatter", hcaes(x = displ, y = hwy, group = class)) %>%
hc_size(width=800, height = 400)
saveWidget(x, 'demox.html', selfcontained = FALSE)
display_html('<iframe src="demox.html", width = 900, height = 500 ></iframe>')