运用python里面的numpy和matplotlib模块就实现想法了。
首先,要知道在python里面画散点图用的是scatter。
同时,scatter里面的参数很有意思,具体可以参考这篇博客。讲的非常详细,mark一下。
直接上程序:
import numpy as np
import matplotlib.pyplot as plt
plt.axis([0, 100, 0, 1])
while 1:
for i in range(100):
for color in ['c', 'k', 'm']:
y = np.random.rand()
plt.scatter(i, y, s=200, c=color, alpha=0.5, marker="*")
plt.pause(0.05)
for i1 in range(100):
for color in ['g', 'b', 'r', 'y']:
y2 = np.random.rand()
plt.scatter(i1, y2, s=300, c=color, alpha=0.1, marker="o")
plt.pause(0.05)
效果图如下: