1.练习代码
'''
fileName = input('请输入文件名称:')
contentList = '我是你妈妈'
fileOpen = open(fileName,'a+')
fileOpen.write(contentList)
fileOpen.seek(0)
for line in fileOpen.readlines():
print(line)
import numpy as np
x = [
[1,2,3,4],
[4,3,2,1],
[5,6,7,8],
[9,8,7,6]
]
print(type(x))
print(np.array(x).transpose())
print(type(np.array(x).transpose()))
print(np.array(x).T)
y = np.mat(x)
print(y.transpose())
print(type(y))
z = np.matrix(x)
print(z.T)
print(type(z))
x = np.array(range(10))
print(x)
print(x[x>4])'''
import numpy as np
import matplotlib.pyplot as plt
'''
fig = plt.figure() #首先要定义一个figure对象,可以理解成一张画板
ax1 = fig.add_subplot(221) #添加轴,可以理解为建立平面直角坐标系
ax1.set(xlim = [0,100],ylim = [-1,1],title = 'an example axes',ylabel = "金钱/t",xlabel = '时间/s')
#plt.show()
ax2 = fig.add_subplot(222)
ax3 = fig.add_subplot(223)
ax4 = fig.add_subplot(224)
ax4.set(xlim = [0,100],ylim = [-1,1],title = 'you mother fucker',ylabel = 'y-axis',xlabel = 'x-ax')
x = np.linspace(0,100,10000)
y = np.cos(x)
ax1.plot(x,y,'-',linewidth = '2',markersize = '12',color = 'green')
ax4.plot(x,y,'--')
plt.show()
plt.plot(x,y,ls = '-',label = 'plot figure',lw = 2)
plt.legend()
plt.show()
fig = plt.figure()
axes = plt.subplots(norows = 2,ncols = 2)
x = np.linspace(0,np.pi)
y_sin = np.sin(x)
y_cos = np.cos(x)
y_constant = x * 0 + 5
axes[0,1].set(title = '11111111',color = 'red')
axes[1,1].set(title = '44444444',color = 'green')
plt.show()'''
import numpy as np
import matplotlib.pyplot as plt
#首先创建对象
fig = plt.figure(figsize=(8,4),facecolor='red')
fig.show()