[英]Increase the font size for a map label
我在下面有這個代碼,它創建了一個 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)
其他一切都好;但是,我想讓城市的名字更大一些。
我可以做些什么來增加城市名稱的字體大小,如下面的代碼輸出所示?
任何人都會受到高度贊賞。
謝謝!
我沒有經常玩這個,但是.annotate
沒有size
參數嗎?
像這樣的東西:
plt.annotate(s=row['NAME_2'], xy=row['coords'], horizontalalignment='center', size=99, )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.