【发布时间】:2021-08-27 15:50:21
【问题描述】:
所以我创建了一个 matplotlib 图形,然后通过 shape 文件添加 3 个(德国、斯洛伐克、捷克)国家。
我明确地将 figsize 设置为 (15, 15)。 germany、czech、slovakia 是读取的形状文件,最后germany_pipe 是GeoDataFrame,它在matplotlib 图中添加了蓝线。
fig, ax = plt.subplots(1, 1, figsize=(15, 15))
germany.plot(ax=ax, color='lightgray', edgecolor='white')
germany_pipe.plot(ax=ax, color='cornflowerblue',
linewidth=germany_pipe['diameter'].values/400)
czech.plot(ax=ax, color='lightgray', edgecolor='white')
slovakia.plot(ax=ax, color='lightgray', edgecolor='white')
此图后如下图:
然后我还绘制了另一个GeoDataFrame,它将其他行绘制为红色,通过:data_geo.plot(ax=ax, color='red', linewidth=data_geo['diameter'].values/400)
然而,在这一点之后,matplotlib 图形由于某种原因改变了大小。 你知道这是什么原因吗?
print(data_geo.crs)
None
print(germany_pipe.crs)
epsg:4326
【问题讨论】:
-
请显示以下内容的输出:
germany.crs、data_geo.crs。它们是一样的吗? -
@swatchai 我将它们添加到问题中
-
哇,我设置
data_geo.crs = 'epsg:4326'后,它起作用了,请写一个答案,我会接受! @swatchai
标签: python matplotlib size geopandas figure