首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >增加地图标注的字体大小

增加地图标注的字体大小
EN

Stack Overflow用户
提问于 2020-03-05 08:32:54
回答 1查看 568关注 0票数 0

我有下面的代码来创建一个shapefile的地图:

代码语言:javascript
复制
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt

pm10_base = gpd.read_file('/Users/jacob/Desktop/MSthesis/wrfpy/actual/mmshp/population_by_lgu.shp')






# set the value column that will be visualised
variable = 'NAME_2'

# create figure and axes for Matplotlib
fig, ax = plt.subplots(1, figsize=(8, 10))
# remove the axis
ax.axis('off')
# add a title and annotation
ax.set_title('Metro Manila LGU Division ', fontdict={'fontsize': '20', 'fontweight' : '4'})

# create map
pm10_base.plot(column='NAME_2', alpha= 0.9, linewidth=0.02, ax=ax, edgecolor='0.8')


# Add Labels
pm10_base['coords'] = pm10_base['geometry'].apply(lambda x: x.representative_point().coords[:])
pm10_base['coords'] = [coords[0] for coords in pm10_base['coords']]
for idx, row in pm10_base.iterrows():
    plt.annotate(s=row['NAME_2'], xy=row['coords'],horizontalalignment='center', )



plt.savefig('/Users/jacob/Desktop/figure312.png', bbox_inches = 'tight', pad_inches = 0)

其他一切都可以;但是,我想让城市的名称更大一些。

我可以做什么来增加城市名称的字体大小,如以下代码的输出所示?

任何帮助都将不胜感激。

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2020-03-05 08:42:50

我不经常使用它,但是.annotate不是有一个size参数吗

如下所示:

plt.annotate(s=row['NAME_2'], xy=row['coords'], horizontalalignment='center', size=99, )

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60536615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档