在R中的同一绘图中使用plotly软件包绘制两个图形

在R中的同一绘图中使用plotly软件包绘制两个图形,r,shiny,plotly,R,Shiny,Plotly,如何在同一窗口中绘制两个图形 library(shiny) library(plotly) shinyServer(function(input, output) { today <- Sys.Date() tm1 <- c(2,3,5,7,9) tm2 <- c(3,4,6,8,9) x1 <- today + tm1 x2 <- today + tm2 y1 <- rnorm(length(x1)) y2 <- rnorm(length(x2))

如何在同一窗口中绘制两个图形

library(shiny)

library(plotly)

shinyServer(function(input, output) {
today <- Sys.Date()
tm1 <- c(2,3,5,7,9)
tm2 <- c(3,4,6,8,9)
x1 <- today + tm1
x2 <- today + tm2
y1 <- rnorm(length(x1))
y2 <- rnorm(length(x2))
output$p <- renderPlot( plot_ly(x = ~x1, y = ~y1, text = paste(tm1), mode = 'markers'))
output$p1 <- renderPlot ( plot_ly(x = ~x1, y = ~y2,text = paste(tm2, "days  today"), mode = 'markers', color = '4'))

})
库(闪亮)
图书馆(绘本)
shinyServer(功能(输入、输出){

今天我认为你应该使用子情节来实现你的目标。下面解释一下:

第一个示例的代码是:

library(plotly)
p1 <- plot_ly(economics, x = ~date, y = ~unemploy) %>%
  add_lines(name = ~"unemploy")
p2 <- plot_ly(economics, x = ~date, y = ~uempmed) %>%
  add_lines(name = ~"uempmed")
p <- subplot(p1, p2)

# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link <- plotly_POST(p, filename = "subplot/basic")
chart_link
library(plotly)
p1%
添加行(名称=~“取消雇用”)
p2%
添加_行(名称=~“uempmed”)

p我认为你应该使用子情节来实现你的目标。下面对它们进行了解释:

第一个示例的代码是:

library(plotly)
p1 <- plot_ly(economics, x = ~date, y = ~unemploy) %>%
  add_lines(name = ~"unemploy")
p2 <- plot_ly(economics, x = ~date, y = ~uempmed) %>%
  add_lines(name = ~"uempmed")
p <- subplot(p1, p2)

# Create a shareable link to your chart
# Set up API credentials: https://plot.ly/r/getting-started
chart_link <- plotly_POST(p, filename = "subplot/basic")
chart_link
library(plotly)
p1%
添加行(名称=~“取消雇用”)
p2%
添加_行(名称=~“uempmed”)

p在同一窗口中?在一个绘图中?或在屏幕的两个分区中?仅在一个绘图中添加您的UIC代码。在同一窗口中?在一个绘图中?或在屏幕的两个分区中?仅在一个绘图中添加您的UIC代码。