W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
# 这三行代码让编译器支持绘图功能:
import sys
import matplotlib
matplotlib.use('Agg')
​
import matplotlib.pyplot as plt
import numpy as np
​
ypoints = np.array([3, 8, 1, 10])
​
# 绘制带黄色(y)圆形(o)标记的折线图
plt.plot(ypoints, 'oy')
plt.show()
​
# 这两行代码实现图形输出:
plt.savefig(sys.stdout.buffer)
sys.stdout.flush()