使用R中相同图中的绘图包绘制两个图

时间:2016-11-30 06:39:03

标签: 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))
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'))

})

1 个答案:

答案 0 :(得分:2)

我认为你应该使用子图来实现你的目标。这里解释了它们:https://plot.ly/r/subplots/

第一个例子的代码是:

a {
  transition: text-shadow 1s;
}
a:hover {
  text-shadow: 1px 0 black;
}

希望它有所帮助: - )

相关问题