import matplotlib.pyplot as plt
import numpy as np
plt.figure(figsize=(8,6),facecolor=‘black’)
x=np.arange(0,2*np.pi,0.1)
y1=np.sin(x)
y2=np.cos(x)
plt.scatter(x,y1,c=‘pink’,s=50)
plt.scatter(x,y2,c=y2,cmap=‘rainbow’)
plt.legend([‘y=sinx’,‘y=cosx’],facecolor=‘gray’)
plt.savefig(‘scatter.png’)
p1=plt.figure(figsize=(3,4),facecolor=‘black’)
p1.add_subplot(3,1,1)
x=np.arange(0,2*np.pi,0.2)
y1=np.sin(x)
plt.scatter(x,y1)
plt.xlabel(‘x’)
plt.xticks([1,2,3,4,5,6])
pllt.yticks([-1,0,1])
p1.add_subplot(3,1,2)
y2=np.cos(x)
plt.scatter(x,y2)
p1.add_subplot(3,1,3)
plt.scatter(np.cos(x),np.sinx(x))
plt.show()
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams[‘font.sans-serif’]=‘SimHei’
plt.rcParams[‘axes.unicode_minus’]=False
plt.rcParams[‘axes.facecolor’]=’#0D0434’
plt.rcParams[‘axes.edgecolor’]=‘red’
plt.rcParams[‘xtick.color’]=‘white’
plt.rcParams[‘ytick.color’]=‘white’
font={
‘family’:‘SimHei’, # 字体
‘weight’:‘normal’, # 字的宽度
‘size’:16, # 大小
‘color’:‘white’ # 颜色
}
p1=plt.figure(figsize=(8,8),facecolor=‘black’)
plt.suptitle(‘总 图’,fontdict=font)
plt.subplots_adjust(hspace=0.1,wspace=0.1,right=0.2)
p1.add_subplot(3,2,1)
x=np.arange(0,2*np.pi,0.3)
x1=np.arange(-np.pi/2,np.pi/2,0.3)
y1=np.sin(x1)
plt.scatter(x1,y1,c=‘red’)
p1.add_subplot(6,2,2)
y2=np.sin(x)
plt.scatter(x,y2,c=‘yellow’)
p1.add_subplot(6,2,4)
y3=np.cos(x)
plt.scatter(x,y3,c=‘yellow’)
p1.add_subplot(3,1,2)
y4=np.sin(x)
y5=np.cos(x)
plt.title(‘正余弦曲线’,fontdict=font)
plt.xlabel(‘x轴’,fontdict=font)
plt.ylabel(‘y轴’,fontdict=font)
plt.xticks([1,2,3,4,5,6])
plt.yticks([-1,0,1])
plt.scatter(x,y4,c=y4,cmap=‘rainbow’)
plt.scatter(x,y5,c=‘pink’)
plt.legend([‘y=sinx’,‘y=cosx’],facecolor=‘gray’)
p1.add_subplot(3,2,5)
plt.scatter(np.cos(x),np.sin(x),c=‘blue’)
p1.add_subplot(3,2,6)
plt.scatter(np.cos(x),np.sin(x),c=‘blue’)
plt.show()