简体   繁体   English

在 R 中绘图 - 指定等值线图的 bin 大小

[英]plotly in R - specifying bin size for choropleth maps

When creating a choropleth map using the plotly package in R, is there any way to specify the bin size?使用 R 中的 plotly 包创建 choropleth 地图时,有没有办法指定 bin 大小?

Example:例子:

library(plotly)
df <- read.csv("https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv")
plot_ly(df, z=total.exports, locations=code, type="choropleth", locationmode="USA-states", colors = 'Purples', filename="", colorbar=list(title = "2011 US Agriculture Exports by State")) %>% 
layout(geo = list(scope="usa"))

Currently, the above code auto-bins into 2k steps.目前,上述代码自动分箱为 2k 步。 If I wanted say 5k steps and a max value of 30k, how would I do that?如果我想说 5k 步和 30k 的最大值,我该怎么做? I was hoping there would be something like this (as there is with histograms):我希望会有这样的东西(就像直方图一样):

bins = list(start = 0, end = 30000, size = 5000)

正如@dww 所建议的,使用 4.x 版:

plot_ly(df, z=~total.exports, locations=~code, zmin=0, zmax = 30000, type="choropleth", locationmode="USA-states", colors = 'Purples', filename="", colorbar=list(title = "2011 US Agriculture Exports by State")) %>% layout(geo = list(scope="usa"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM