python语言作图

可以在浏览器中访问这里输入代码运行: https://mybinder.org/v2/gh/jupyterlab/jupyterlab-demo/master?urlpath=lab

可以在浏览器中访问这里输入代码运行: https://jupyter.org/try-jupyter/retro/notebooks/?path=notebooks/Intro.ipynb

例子一:

import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [2, 4, 3])

plt.show()

例子二:

import matplotlib.pyplot as plt

x = [-1, 0, 0, -1]

y = [2, 3, 0, 2]

x2 = [0, 2, 3, 0]

y2 = [0, 1, 0, 0]

plt.plot(x, y, label=’First’)

plt.plot(x2, y2, label=’Second’)

plt.xlabel(‘X’)

plt.ylabel(‘Y’)

plt.title(‘Rotate’)

plt.legend()

plt.show()

例子三:

import matplotlib.pyplot as plt

x3 = [2, 4, 5, 2]

y3 = [0, 1, 0, 0]

x4 = [-2, -4, -5, -2]

y4 = [0, -1, 0, 0]

x = [-5, 5]

y = [0, 0]

x1 = [0, 0]

y1 = [5, -5]

plt.plot(x, y, label=”)

plt.plot(x1, y1, label=”)

plt.plot(x3, y3, label=’Third’)

plt.plot(x4, y4, label=’Fourth’)

plt.xlabel(‘X’)

plt.ylabel(‘Y’)

plt.title(‘Rotate’)

plt.legend()

plt.show()

发表评论