为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我在 python 中的散点图在使用“s”参数时给出全红色

为什么我在 python 中的散点图在使用“s”参数时给出全红色

沧海一幻觉 2021-05-30 21:00:23
当我将 s 参数用于气泡整个图时为红色 当使用“s”参数时# Import numpy as npimport numpy as np# Store pop as a numpy array: np_popnp_pop = np.array(pop)# Double np_popnp_pop = np_pop*2# Update: set s argument to np_popplt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red', s = np_pop)# Previous customizationsplt.xscale('log') plt.xlabel('GDP per Capita [in USD]')plt.ylabel('Life Expectancy [in years]')plt.title('World Development in 2007')plt.xticks([1000, 10000, 100000],['1k', '10k', '100k'])# Display the plotplt.show()当不使用s参数时,它显示恒定的气泡大小,但是当不使用s参数时,我希望气泡大小取决于填充量 ,所以不显示红色# Import numpy as npimport numpy as np# Store pop as a numpy array: np_popnp_pop = np.array(pop)# Double np_popnp_pop = np_pop*2# Update: set s argument to np_popplt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red')# Previous customizationsplt.xscale('log') plt.xlabel('GDP per Capita [in USD]')plt.ylabel('Life Expectancy [in years]')plt.title('World Development in 2007')plt.xticks([1000, 10000, 100000],['1k', '10k', '100k'])# Display the plotplt.show()
查看完整描述

1 回答

?
杨魅力

TA贡献1811条经验 获得超6个赞

尝试使用较小的np_pop

np_pop = np_pop/5000 # or any other value that decrease the population(?)


查看完整回答
反对 回复 2021-06-01
  • 1 回答
  • 0 关注
  • 180 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号