W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
# 这三行代码使编译器能够绘图:
import sys
import matplotlib
matplotlib.use('Agg')
​
import matplotlib.pyplot as plt
import numpy as np
​
xpoints = np.array([0, 6])  # x 轴坐标范围从 0 到 6
ypoints = np.array([0, 250])  # y 轴坐标范围从0 到 250
​
plt.plot(xpoints, ypoints)  # 绘制两点之间的直线
plt.show()
​
# 这两行代码使编译器能够输出图形:
plt.savefig(sys.stdout.buffer)
sys.stdout.flush()