7
我已经创建了熊猫棒图,其中显示了某些国家和地区的数量变化情况,并根据各个国家/地区设置了酒吧颜色。我使用下面的代码绘制图表。该代码是基于this question第二应答:Pandas酒吧阴谋(matplotlib)中的自定义传说
s = pd.Series(
listOfQuantities,
listOfCountiesNames
)
''' Assign color to each country based on the continent '''
colormapping = {'AF':'k','AS':'r','EU':'g','OC':'r','NA':'b','SA':'y'}
colorstring = ""
for country in listOfCountiesNames:
continent = countryToContinent[country]
colorstring += colormapping[continent]
pd.Series.plot(
s,
kind='bar',
color=colorstring,
grid=False,
)
我想创建像一个我显示附加的图像在图例中(不是由蟒产生的图例,我手动添加)。是否有可能用熊猫来绘制这样的自定义图例,还是我可以实现与其他图形库类似的东西?此外,我会很欣赏这种类型的数据的替代剧情类型的建议。