我下面的代码创建一个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)
其他都可以;但是,我想扩大城市的名称。
如何从下面的代码输出中看到,增加城市名称的字体大小?
任何人将不胜感激。
谢谢!
我没玩太多,但是size
没有.annotate
参数吗?
类似这样的东西:
plt.annotate(s=row['NAME_2'], xy=row['coords'], horizontalalignment='center', size=99, )