matplotlib 散点图
程序员文章站
2022-03-18 21:37:28
...
import matplotlib.pyplot as plt
import numpy as np
# 保证图片在浏览器内正常显示
import time
start=time.time()
# 10个点
N = 10
x = ['Sur', "Fea", "Dis", "Hap", "Sad", "Ang", "Nat", "XXX", "YYY", "ZZZ"]
y = [0,10,20,30,40,50,60,70,80,90]
# 每个点随机大小
s = 100
# 随机颜色
c = np.random.rand(N)
plt.ylim(0,100)
ax = plt.gca()
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
plt.scatter(x, y, s=s, c=c, alpha=0.5)
print(time.time()-start)
plt.show()
if __name__ == '__main__':
pass
上一篇: matplotlib事件处理