【发布时间】:2020-08-30 17:10:12
【问题描述】:
我在plotly community forum 上发布了这个,但绝对没有任何活动!希望您能在这里提供帮助:
我有地图时间序列数据,有些国家没有数据,plotly 根本没有绘制它们。我可以对它们进行概述,它们看起来不同,但那里似乎没有数据丢失(即我想要一个图例条目)。我怎样才能做到这一点?这是一个代表:
library(plotly)
library(dplyr)
data = read.csv('https://github.com/lc5415/COVID19/raw/master/data.csv')
l <- list(color = toRGB("grey"), width = 0.5)
g <- list(
scope = 'world',
countrycolor = toRGB('grey'),
showframe = T,
showcoastlines = TRUE,
projection = list(type = 'natural earth')
)
map.time = data %>%
plot_geo() %>%
add_trace(z = ~Confirmed, color = ~Confirmed, frame = ~Date, colors = 'Blues',
text = ~Country, locations = ~Alpha.3.code, marker = list(line = l)) %>%
colorbar(title = 'Confirmed') %>%
layout(
title = 'Number of confirmed cases over time',
geo = g
) %>%
animation_opts(redraw = F) %>%
animation_slider(
currentvalue = list(
prefix = paste0("Days from ",
format(StartDate, "%B %dnd"),": "))) %>%
plotly_build()
map.time
请注意,缺少数据的国家(例如俄罗斯)的数据点与所有其他国家一样多,问题不在于它们没有出现在传递给 plotly 的 dtaframe 中。
【问题讨论】: