我正在使用plotly express创建choropleth图表。我想用这些箱子制作一个离散色标:[−[0,50]、[0,50]、[50100]、[100150]、[150200]、[200250]、[250300]、[300350]、[350400]、[400450]和[450500]。下面是我的数据帧片段
Country 1990 2019 Code PGR
0 Afghanistan 12.4 38.0 AFG 206.451613
1 Albania 3.3 2.9 ALB -12.121212
2 Algeria 25.8 43.1 DZA 67.054264
我可以获得要显示的绘图,但我不知道如何获得颜色集。到目前为止,我的代码是:
fig = px.choropleth(popCodes,locations= popCodes["Code"],
color = popCodes["PGR"],
range_color = (-50, 500),
hover_name = popCodes["Country"],
color_discrete_sequence=px.colors.sequential.Plasma)
fig.show()
.astype(str)
没有罗布·雷蒙德的回答那么整洁,但我就是这么做的。如果我是你,我会用罗布的
相关问题 更多 >
编程相关推荐