发布时间:2019-09-15 10:10:38编辑:auto阅读(2182)
#!/usr/bin/python
import numpy as np
import pylab as pl
x = [1, 2, 3, 4, 5] # Make an array of x values
y = [1, 4, 9, 16, 25] # Make an array of y values for each x value
pl.plot(x, y) # use pylab to plot x and y
pl.show() # show the plot on the screen
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
xData = np.arange(0, 10, 1)
yData1 = xData.__pow__(2.0)
yData2 = np.arange(15, 61, 5)
plt.figure(num=1, figsize=(8, 6))
plt.title('Plot 1', size=14)
plt.xlabel('x-axis', size=14)
plt.ylabel('y-axis', size=14)
plt.plot(xData, yData1, color='b', linestyle='--', marker='o', label='y1 data')
plt.plot(xData, yData2, color='r', linestyle='-', label='y2 data')
plt.legend(loc='upper left')
plt.savefig('/home/plot1.png', format='png')
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 1000)
y = np.sin(x)
z = np.cos(x**2)
plt.figure(figsize=(8,4))
plt.plot(x,y,label="sin(x)",color="red",linewidth=2)
plt.plot(x,z,"b--",label="cos(x^2)")
plt.xlabel("Time(s)")
plt.ylabel("Volt")
plt.title("PyPlot First Example")
plt.ylim(-1.2,1.2)
plt.legend()
plt.show()
上一篇: Python下三级菜单实现
下一篇: Python/NodeJS坑记
47842
46390
37284
34733
29313
25973
24916
19951
19545
18030
5792°
6413°
5927°
5961°
7064°
5911°
5944°
6438°
6404°
7778°