python - 为什么我在 python 中的散点图在使用“s”参数时全部显示为红色
问题描述
当我对气泡使用 s 参数时,整个图是红色 的 当使用“s”参数时
# Import numpy as np
import numpy as np
# Store pop as a numpy array: np_pop
np_pop = np.array(pop)
# Double np_pop
np_pop = np_pop*2
# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red', s = np_pop)
# Previous customizations
plt.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 plot
plt.show()
当不使用 s 参数时,它显示恒定的气泡大小,但我希望气泡大小取决于人口 当不使用 s 参数时,它不显示红色
# Import numpy as np
import numpy as np
# Store pop as a numpy array: np_pop
np_pop = np.array(pop)
# Double np_pop
np_pop = np_pop*2
# Update: set s argument to np_pop
plt.scatter(gdp_cap, life_exp ,alpha = 0.8,color ='red')
# Previous customizations
plt.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 plot
plt.show()
解决方案
尝试使用较小的np_pop
:
np_pop = np_pop/5000 # or any other value that decrease the population(?)
推荐阅读
- api - 服务器到服务器通信应该使用什么 api 身份验证方法?
- r - 如何从 R 中的 fitdistrplus 包中更改 denscomp 图中的线条粗细?
- android - Firestore - 使用 Where 子句和 startAt 具有不同的字段
- amazon-web-services - 使用 DynamoDB 和 Lambda 存储用户信息的最佳方式是什么?
- python - 无法使用 Python django 在 HTML 网页中查看 PPT
- python - 如何使 cv2.VideoWriter 更轻
- emv - 确定 EMV 卡的发行人
- python - 在 Python 中使用 break 命令时出错
- python - EC2 实例上的 Django + PostgreSQL 备份和恢复
- javascript - 如何根据javascript中的条件订购安排?