问题描述
fig,(ax1,ax2) = plt.subplots(2,1,figsize=(15,17),sharex=True)
sns.scatterplot(data=merged,x="gdp_per_capita",y="life_expectancy",size="death_rate",hue="continent",cmap="Accent",sizes=(100,1500),ax=ax1)
sns.scatterplot(data=merged,y="human_development_index",ax=ax2)
ax1.set(xlabel='GDP per Capita',ylabel ='Life Expectancy',title='Choose')
ax2.set(xlabel='GDP per Capita',ylabel ='Human Development Index',title='Choose')
# show the graph
plt.show()
如何将图例分成两部分,一个是右上角的大陆颜色,另一个是右下角的死亡率气泡大小?那么气泡是否符合图例?
PS:出于测试目的,这里是一个使用“tips”数据集的类似示例:
import seaborn as sns
tips = sns.load_dataset('tips')
tips["percentage"] = tips["tip"] / tips["total_bill"] * 100
sns.scatterplot(data=tips,x="total_bill",y="tip",hue="time",size="percentage",1500))
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)