首页 > 解决方案 > 如何使用管道工在网络上显示/发送 r plotly 图?

问题描述

我有一个情节图,我想使用 R Plumber 在其他 UI(例如角度)上显示情节。

标签: rr-plotlyplumber

解决方案


这是您的操作方法:

# API for experimenting with html widgets

library(plumber)
library(ggplot2)
library(plotly)

#* @apiTitle HTML widgets API

#* Return interactive plot using plotly
#* @serializer htmlwidget
#* @get /plotly
function() {
  p <- ggplot(data = diamonds,
              aes(x = cut, fill = clarity)) +
    geom_bar(position = "dodge")

  ggplotly(p)
}

希望这可以帮助。

来源 - https://github.com/blairj09/plumber-playground/blob/master/experiments/htmlwidgets-exp/plumber.R


推荐阅读