我正在使用提供的示例并将其扩展以生成两个等值线的子图,如下所示。我只得到一个情节并且比例更高:
library(plotly)
df <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv")
df$hover <- with(df, paste(state, '<br>', "Beef", beef, "Dairy", dairy, "<br>", "Fruits", total.fruits, "Veggies", total.veggies,
"<br>", "Wheat", wheat, "Corn", corn))
# give state boundaries a white border
l <- list(color = toRGB("white"), width = 2)
# specify some map projection/options
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showlakes = TRUE,
lakecolor = toRGB('white')
)
p1 <- plot_ly(df, z = total.exports, text = hover, locations = code, type = 'choropleth', locationmode = 'USA-states', color = total.exports, colors = 'Purples',
marker = list(line = l), colorbar = list(title = "Millions USD"))
p2 <- plot_ly(df, z = total.exports, text = hover, locations = code, type = 'choropleth', locationmode = 'USA-states', color = total.exports, colors = 'Purples',
marker = list(line = l), colorbar = list(title = "Millions USD"))
plotly::subplot(p1, p2, nrows = 2) %>% layout(geo = g)
我有什么误解或遗漏?