1

我认为下面的 R Markdown (Rmd) 代码应该生成一个嵌入了曲面图的 html 文档。

```{r, plotly=TRUE}
library(plotly)
py <- plotly()

x_vec = c(seq(-5, 4.9, 0.1))
x_matrix = matrix(c(x_vec), nrow = 100, ncol = 1)
y_matrix = matrix(c(x_vec), nrow = 1, ncol = 100)

data <- list(
  x = x_vec,
  y = x_vec,
  z = matrix(c(cos(x_matrix %*% y_matrix) + sin(x_matrix %*% y_matrix)), nrow = 100, ncol = 100),
  type = "surface")

layout <- list(
  title = "Waaaves in r",
  scene = list(bgcolor = "rgb(244, 244, 248)"))

    response <- py$plotly(data, session="knitr",
                          kwargs = list(
                            layout = layout,
                            world_readable=FALSE,
                            filename = "waves example",
                            fileopt = "overwrite"))

```

该文档使用嵌入的代码创建输出,但没有绘图。只是一条错误消息说,

“呃哦,服务器出错了。”

知道这里发生了什么吗?

4

1 回答 1

0

而不是运行py$plotly(),运行py$irplot()(不带session="knitr"参数)。后者适用于py$ggplotly()方法,而不是方法py$plotly()

于 2015-05-07T14:53:04.010 回答