我有一个笔记本(GitHub链接),使用geopandas绘制着不同国家的地图,并对其进行颜色编码。取决于绘图的顺序,有时它可能没有遵循我指定的figsize()大小。我在Ubuntu 20.04和Firefox上本地运行jupyter,以及在Chromium上运行的Binder和Colab中都反复看到这种行为。
请问有人能帮我理解发生了什么?这是一个错误吗?还是我控制geopandas/matplotlib的方式有误?
(此外,对于我的一些学生(但不是所有学生!),那个破碎的情节中也没有浅灰色背景的国家。这是否可能是导致该方面问题的结果/副作用?)
请问有人能帮我理解发生了什么?这是一个错误吗?还是我控制geopandas/matplotlib的方式有误?
import matplotlib.pyplot as plt
import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
sixc = world[ world['continent'] != 'Antarctica' ]
asia = world[ world['continent'] == 'Asia' ]
noam = world[ world['continent'] == 'North America']
swed = world[ world['iso_a3'] == 'SWE' ]
# This works, makes a 2x1 landscapey aspect
axes = sixc.plot(figsize=(8,4), color='lightgrey')
asia.plot(ax=axes, color='green')
noam.plot(ax=axes, color='purple')
# Plotting swed at the end breaks figsize, makes it squareish
axes = sixc.plot(figsize=(8,4), color='lightgrey')
asia.plot(ax=axes, color='green')
noam.plot(ax=axes, color='purple')
swed.plot(ax=axes, color='yellow')
# Plotting swed in the middle makes it ok again
axes = sixc.plot(figsize=(8,4), color='lightgrey')
asia.plot(ax=axes, color='green')
swed.plot(ax=axes, color='yellow')
noam.plot(ax=axes, color='purple')
(此外,对于我的一些学生(但不是所有学生!),那个破碎的情节中也没有浅灰色背景的国家。这是否可能是导致该方面问题的结果/副作用?)
gpd.__version__
。 - swatchai