Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何导入自己的数据并用作数据标签:如导入各省的某病发病率,并标记在图上(可选择用数值展示或颜色深浅展示) #64

Open
caozpy opened this issue Aug 10, 2022 · 3 comments
Assignees
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@caozpy
Copy link

caozpy commented Aug 10, 2022

体验了一下cnmaps,使用还是很友好方便的。之前一直用R画地图,发现python也不错。有个诉求就是(相信也是很多人的诉求):我们经常需要在地图上标记出各个省,乃至各个城市的某项数据(可以是用具体的34,35,89,112等数值,也可以用颜色),不知道作者有没有考虑

@Clarmy
Copy link
Member

Clarmy commented Aug 10, 2022

@caozpy 如果是颜色的话,我猜你想要的效果是这种:

import numpy as np
from cnmaps import get_adm_maps

provinces = get_adm_maps(level='省', engine='geopandas')
provinces['发病率'] = np.random.random(len(provinces)) * 100
provinces.plot(column='发病率')
plt.savefig('./result.png')

result

如果是标记数字的话,可能需要增加查找城市坐标点的功能,有这个计划: #11

@Clarmy Clarmy added the good first issue Good for newcomers label Aug 10, 2022
@Clarmy Clarmy self-assigned this Aug 10, 2022
@Clarmy Clarmy added the help wanted Extra attention is needed label Aug 10, 2022
@caozpy
Copy link
Author

caozpy commented Aug 10, 2022

是的,赞

@Clarmy
Copy link
Member

Clarmy commented Aug 10, 2022

这个其实是 GeoPandas 的地图绘制功能,调用 get_adm_maps 时传入参数 engine='geopandas' 以后,返回的对象是 geopandas.geodataframe.GeoDataFrame 对象,就可以根据 GeoPandas 所支持的功能绘图了。参考示例

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants