在R中绘制-指定choropleth贴图的面元大小

在R中绘制-指定choropleth贴图的面元大小,r,plotly,choropleth,R,Plotly,Choropleth,在R中使用plotly软件包创建choropleth地图时,是否有任何方法指定存储箱大小 例如: 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-st

在R中使用plotly软件包创建choropleth地图时,是否有任何方法指定存储箱大小

例如:

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"))
library(plotly)
df%
布局(地理=列表(scope=“usa”))
目前,上述代码自动存储箱分为2k个步骤。如果我想说5k步,最大值30k,我该怎么做?我希望会出现这样的情况(直方图也是如此):

bin=list(开始=0,结束=30000,大小=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"))

您使用的是什么版本?最新的4.x似乎只支持z的连续变量,带有连续的颜色条图例。如果您的版本支持分类z值,那么您可以尝试
df$grp=cut(df$total.exports,c(0500010000015000…
)来生成您的类别,然后使用grp列为choropleth着色谢谢!这很有帮助。我几个月前才安装了该软件包,但它看起来像是最新版本(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美国农业出口按州划分”)%>%layout(geo=list(scope=“USA”)).我也尝试了使用df$grp的分类z值方法,但它似乎生成了一个灰色地图。但是zmin/zmax方法也可以工作,所以我对此没有意见