Guest User

Untitled

a guest
Aug 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.97 KB | None | 0 0
  1. > dput(dt[1:50,.(lat, lon, mw, current_year)])
  2. structure(list(lat = c(33.5812648426403, 33.5812648426403, 34.0668345432655,
  3. 33.6961126585264, 34.0668345432655, 41.2963261323817, 27.878260812094,
  4. 39.5272127787272, 41.7952019373576, 41.298797861735, 42.6404243603087,
  5. 44.7034406661987, 39.1547560972326, 39.5872026391932, 40.4542882818925,
  6. 40.6479177474976, 35.6200162972977, 34.5709360758464, 35.2237865046451,
  7. 32.7985594613211, 31.5559690263536, 31.5559690263536, 32.4392329624721,
  8. 29.2475475692749, 28.508979373508, 41.5753456115723, 44.3516218012029,
  9. 37.7541649917076, 33.0466017150879, 30.8503398895264, 33.5812648426403,
  10. 41.4192822047642, 40.0061813195546, 42.6477045331682, 41.4192822047642,
  11. 44.1539509513161, 40.0926746931232, 41.4942982991536, 40.7539427621024,
  12. 41.7855738004049, 41.4942982991536, 37.9775902557373, 41.3185318840875,
  13. 41.5753456115723, 40.4008912222726, 40.6867153712681, 33.0070703946627,
  14. 33.0070703946627, 33.0070703946627, 32.2995414733887), lon = c(-111.886676718972,
  15. -111.886676718972, -118.294102238674, -117.736324001003, -118.294102238674,
  16. -73.3511804318895, -82.4752747291742, -86.497910563151, -70.2159778806898,
  17. -70.0584147135417, -70.983841879326, -93.0496198866102, -74.807897679946,
  18. -75.3653199479387, -74.4234486630088, -73.95051612854, -82.5088296007754,
  19. -82.6195589701335, -89.9929729260896, -97.2939638410296, -97.1812811957465,
  20. -97.1812811957465, -97.8751057216099, -95.4604983520508, -96.685354953342,
  21. -86.4192230224609, -86.1332654086026, -77.4094619750977, -114.984835205078,
  22. -90.0291446685791, -111.886676718972, -72.9225483485631, -76.7841037114461,
  23. -89.0048991612026, -72.9225483485631, -94.1275901794434, -80.0676585963515,
  24. -74.2516840154474, -74.0973572503953, -73.8303874333699, -74.2516840154474,
  25. -121.942034454346, -104.699122111003, -86.4192230224609, -112.594391305106,
  26. -76.1847250802176, -111.078885787573, -111.078885787573, -111.078885787573,
  27. -100.947525024414), mw = c(485.7, 323.8, 462, 462, 230, 375.7,
  28. 784, 414, 330, 15.4, 60, 238, 321, 242, 430, 93, 382.4, 486,
  29. 694, 471, 235.5, 471, 471, 100, 204, 10.8, 253, 374, 19, 400,
  30. 510, 100, 469.8, 465.8, 561, 210, 1025, 470, 132, 1170, 12, 444.6,
  31. 80, 476, 30, 250, 714, 241, 723, 477.8), current_year = c(2019,
  32. 2018, 2020, 2020, 2020, 2019, 2021, 2018, 2019, 2019, 2021, 2018,
  33. 2020, 2019, 2018, 2019, 2019, 2018, 2018, 2022, 2020, 2020, 2020,
  34. 2019, 2019, 2019, 2020, 2018, 2018, 2019, 2025, 2018, 2018, 2020,
  35. 2018, 2019, 2020, 2018, 2018, 2020, 2021, 2020, 2022, 2018, 2019,
  36. 2019, 2024, 2023, 2025, 2021)), .Names = c("lat", "lon", "mw",
  37. "current_year"), row.names = c(NA, -50L), class = c("data.table",
  38. "data.frame"), .internal.selfref = <pointer: 0x0000000000330788>)
  39.  
  40. g <- list(
  41. scope = 'usa',
  42. projection = list(type = 'Mercator'),
  43. showland = TRUE,
  44. landcolor = toRGB("gray85"),
  45. subunitwidth = 1,
  46. countrywidth = 1,
  47. subunitcolor = toRGB("white"),
  48. countrycolor = toRGB("white")
  49. )
  50.  
  51. p <- plot_geo(dt, locationmode = 'USA-states', sizes = c(1, 250)) %>%
  52. add_markers(
  53. x = ~lon, y = ~lat,
  54. text = ~paste(mw),
  55. color = ~prime_mover,
  56. size = ~mw,
  57. hoverinfo = "text"
  58. ) %>%
  59. layout(
  60. title = 'Upcoming GT installations in the US<br>(Hover for plant name and year)',
  61. geo = g
  62. )
  63.  
  64. updatemenus = list(
  65. list(
  66. type = "buttons",
  67.  
  68. buttons = list(
  69.  
  70. list(method = "restyle",
  71. args = list("line.color", "blue"),
  72. label = "Blue"),
  73.  
  74. list(method = "restyle",
  75. args = list("line.color", "red"),
  76. label = "Red"))) )
  77.  
  78. plot_geo(locationmode = 'USA-states', sizes = c(1, 250)) %>%
  79. add_markers(data = subset(dt, current_year %in% c("2018")),
  80. x = ~lon, y = ~lat,
  81. text = ~paste(mw),
  82. # color = ~prime_mover,
  83. size = ~mw,
  84. hoverinfo = "text",
  85. name = "2018",
  86. showlegend = FALSE # if you don't want a legend
  87. ) %>%
  88. add_markers(data = subset(dt, current_year %in% c("2019")),
  89. x = ~lon, y = ~lat,
  90. text = ~paste(mw),
  91. # color = ~prime_mover,
  92. size = ~mw,
  93. hoverinfo = "text",
  94. name = "2019"
  95. ) %>%
  96. add_markers(data = subset(dt, current_year %in% c("2020")),
  97. x = ~lon, y = ~lat,
  98. text = ~paste(mw),
  99. # color = ~prime_mover,
  100. size = ~mw,
  101. hoverinfo = "text",
  102. name = "2020"
  103. ) %>%
  104. layout(title = 'Upcoming GT installations in the US<br>(Hover for plant name and year)',
  105. geo = g,
  106. updatemenus = list(
  107. list(
  108. y = 0.8,
  109. # type= 'buttons',
  110. buttons = list(
  111. list(
  112. method = "update",
  113. args = list(list(visible = c(TRUE, FALSE, FALSE))),
  114. label = "2018"),
  115. list(method = "update",
  116. args = list(list(visible = c(FALSE, TRUE, FALSE))),
  117. label = "2019"),
  118.  
  119. list(method = "update",
  120. args = list(list(visible = c(FALSE, FALSE, TRUE))),
  121. label = "2020")))
  122. )
  123. )
Add Comment
Please, Sign In to add comment