我有下面的代码来创建一个shapefile的地图:
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)其他一切都可以;但是,我想让城市的名称更大一些。
我可以做什么来增加城市名称的字体大小,如以下代码的输出所示?
任何帮助都将不胜感激。
谢谢!

发布于 2020-03-05 08:42:50
我不经常使用它,但是.annotate不是有一个size参数吗
如下所示:
plt.annotate(s=row['NAME_2'], xy=row['coords'], horizontalalignment='center', size=99, )
https://stackoverflow.com/questions/60536615
复制相似问题