【问题标题】:How do we return ggplot graphs through plumber web api? [duplicate]我们如何通过管道工 web api 返回 ggplot 图形? [复制]
【发布时间】:2017-06-12 08:33:33
【问题描述】:

我正在使用 ggplot 绘制条形图,并使用 R 中的水管工包将此函数创建为 Web api。

 library(plumber)
 library(ggplot2)
#' @get /histogram_test
#' @png
  histogram_test <- function(){
  mtcars=mtcars
  b=ggplot(mtcars,aes(mtcars$cyl))
  b+geom_bar()
}

然后我运行:

r <- plumb("plum_api.R")
r$run(port=8000)

但这不会在浏览器上返回绘图。

【问题讨论】:

标签: r asp.net-web-api ggplot2 plumber


【解决方案1】:

所以如果在最后一行我们只使用 print 命令,它就可以工作: 打印(b+geom_bar())。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-30
    • 1970-01-01
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-22
    相关资源
    最近更新 更多