绘图对象中包含的故障生成图

时间:2019-04-20 16:34:48

标签: r shiny plotly dashboard r-plotly

我是刚开始绘制并查看网站上提供的许多演示功能的示例仪表板。特别是,当运行以下脚本时,该脚本在绘制纬度/经度坐标之间的连接时应该生成美国地图,因此我会使用RStudio收到以下警告:

警告信息: 现在不建议在layout()中指定宽度/高度。 请在ggplotly()或plot_ly()中指定

此外,在查看器选项卡中看不到任何输出。我已经尝试了其他类似的脚本,其中包含地图,这对我来说是一个始终如一的问题。不知道我是否需要安装另一个软件包,但是我在跟踪提供的软件包。任何帮助将不胜感激!

尝试运行以下脚本

library(plotly)
trace1 <- list(
  hoverinfo = "all", 
  lat = c(39.49857611, 35.40518365526316, 26.53616667), 
  line = list(
    color = "rgb(23, 190, 207)", 
    dash = "dot", 
    width = 3
  ), 
  lon = c(-119.76806470000001, -107.76399163789475, -81.75516667), 
  marker = list(
    autocolorscale = FALSE, 
    color = c("green", "blue", "red"), 
    line = list(
      color = "rgb(0, 0, 0)", 
      width = 2
    ), 
    opacity = 1, 
    reversescale = TRUE, 
    size = c(5, 8.2, 5), 
    sizemode = "diameter", 
    sizeref = 1, 
    symbol = "y-up"
  ), 
  mode = "lines+markers+text", 
  name = "Plane", 
  opacity = 0.8, 
  stream = list(
    maxpoints = 500, 
    token = "your_stream_token_here"
  ), 
  text = c("Reno/Tahoe International", "6,2016-10-01 20:16:38.050736", "Southwest Florida International"), 
  textposition = "top right", 
  type = "scattergeo", 
  uid = "f8f4d9"
)
data <- list(trace1)
layout <- list(
  autosize = TRUE, 
  geo = list(
    countrycolor = "rgb(217, 217, 217)", 
    countrywidth = 0.5, 
    landcolor = "rgb(250, 250, 250)", 
    projection = list(type = "albers usa"), 
    scope = "usa", 
    showland = TRUE, 
    subunitcolor = "rgb(217, 217, 217)", 
    subunitwidth = 0.5
  ), 
  height = 523, 
  margin = list(
    r = 20, 
    t = 20, 
    b = 20, 
    l = 20
  ), 
  title = "", 
  width = 969
)
p <- plot_ly()
p <- add_trace(p, hoverinfo=trace1$hoverinfo, lat=trace1$lat, line=trace1$line, lon=trace1$lon, marker=trace1$marker, mode=trace1$mode, name=trace1$name, opacity=trace1$opacity, stream=trace1$stream, text=trace1$text, textposition=trace1$textposition, type=trace1$type, uid=trace1$uid)
p <- layout(p, autosize=layout$autosize, geo=layout$geo, height=layout$height, margin=layout$margin, title=layout$title, width=layout$width)
p

带有指定点之间的连接的可视化美国下48地图。

请参阅以下链接:

https://plot.ly/dashboard/jackp:16819/view

此外,我无法运行在代码页上注释并收到此通知的任何这些快捷方式:

警告信息: “ get_figure”已弃用。 请改用“ api_download_plot”。 查看帮助(“已弃用”)

get_figure("streaming-demos", 121)
<- get_figure("streaming-demos", 121)$data
p <- add_trace(p, x=c(4, 5), y=c(4, 5), kwargs=list(filename="geo-streaming2", fileopt="extend"))

0 个答案:

没有答案