python - Geopandas 彩色地图未正确显示
问题描述
我有 3 个使用过的数据:
- df_prov = 有省和计数列
- geojson
- df_join = 有省、计数和几何(来自geojson)
这是数据预览: 在此处输入图像描述
0 Sumatera Utara 7430
1 Jawa Barat 6192
2 Jakarta Raya 4635
3 Banten 2351
4 Jawa Timur 1383
5 Jawa Tengah 840
6 Riau 782
7 Sumatera Selatan 526
8 Sumatera Barat 490
9 Bali 459
10 Lampung 379
11 Aceh 377
12 Kalimantan Timur 266
13 Sulawesi Selatan 241
14 Kepulauan Riau 230
15 Yogyakarta 193
16 Jambi 186
17 Bengkulu 133
18 Sulawesi Utara 109
19 Bangka Belitung 98
20 Kalimantan Barat 81
21 Nusa Tenggara Timur 71
22 Papua 55
23 Sulawesi Tengah 54
24 Kalimantan Utara 37
25 Maluku 37
26 Sulawesi Tenggara 33
27 Kalimantan Tengah 31
28 Kalimantan Selatan 30
29 Nusa Tenggara Barat 21
30 Sulawesi Barat 16
31 Gorontalo 11
32 Papua Barat 10
33 Maluku Utara 8
这是一个省和计数的列表,它表明苏门答腊北方的计数是最多的。
但是当我绘制它时,它表明 Kalimantan timur 具有最暗的值,而不是 sumatera utara。
这是代码:[绘图代码2
# set a variable that will call whatever column we want to visualise on the map
values = 'Count'
# set the value range for the choropleth
vmin, vmax = 0,100
# create figure and axes for Matplotlib
fig, ax = plt.subplots(1, figsize=(30, 10))
# remove the axis
ax.axis('off')
# add a title
title = 'Data Persebaran per Provinsi'
ax.set_title(title, fontdict={'fontsize': '25', 'fontweight' : '3'})
# create an annotation for the data source
ax.annotate('Source: Laporan per Juni - November',xy=(0.1, .08), xycoords='figure fraction', horizontalalignment='left', verticalalignment='top', fontsize=12 ,color='#555555')
# norm = mpl.colors.Normalize(vmin=0, vmax=1000)
# Create colorbar as a legend
sm = plt.cm.ScalarMappable(cmap='RdBu', norm=plt.Normalize(vmin=vmin, vmax=vmax))
# add the colorbar to the figure
cbar = fig.colorbar(sm)
# create map
df_join.plot(column=values, cmap='RdBu', linewidth=0.8, ax=ax, edgecolor='0.8', norm=plt.Normalize(vmin=vmin, vmax=vmax))
这是地图: 在此处输入图片描述
你能帮我看看并告诉我代码有什么问题吗?提前致谢!
解决方案
推荐阅读
- javascript - for...of 循环与此常规循环相同吗?
- php - Laravel 更新事件无法正常工作
- c++ - MS 集群 - 如何初始化 RESUTIL_PROPERTY_ITEM 结构?
- javascript - React 是否有相当于 jQuery 无限拖动的功能?
- php - PHP电子表格 | 保存 XLSX 会取消隐藏每一行
- android - 如何在 Android 中使用 Paging 3 库显示空视图
- mysql - 将存储在 mysql LONGTEXT 字段上的 HTML 文本转换为可读值?
- angular - 多数组中的Angular ngFor
- javascript - Puppeteer - 以正确的格式从表中抓取数据
- python-3.x - 在 Databricks 笔记本中使用 Python 从列中获取最大值