グラフの書き方(sin波,cos波)

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker

x=np.linspace(0,2*np.pi,1000) #0~2πまで1000個作成
y1=np.sin(x)
y2=np.cos(x)

fig=plt.figure() #figureを作成
ax1=fig.add_subplot(211) #figure内の2行1列1番目にax1を作成
ax2=fig.add_subplot(212) #figure内の2行1列2番目にax2を作成

ax1.plot(x,y1) #sin波作成
ax2.plot(x,y2) #cos波作成

#図の体裁を整えていく

position=[0,np.pi,np.pi*2] #軸の主要値
labels=['0','π','2π']      #軸の主要値の名前

ax1.set_title("sin wave") #図のタイトル
ax1.set_xlabel("phase")   #x軸の名前
ax1.set_ylabel("voltage") #y軸の名前
ax1.xaxis.set_major_locator(ticker.FixedLocator(position))   #軸の主要値の場所を指定
ax1.xaxis.set_major_formatter(ticker.FixedFormatter(labels)) #軸の主要値の名前を指定


ax2.set_title("cos wave") #図のタイトル
ax2.set_xlabel("phase")   #x軸の名前
ax2.set_ylabel("voltage") #y軸の名前
ax2.xaxis.set_major_locator(ticker.FixedLocator(position))   #軸の主要値の場所を指定
ax2.xaxis.set_major_formatter(ticker.FixedFormatter(labels)) #軸の主要値の名前を指定

plt.tight_layout() #グラフのラベルやタイトルが重ならないようにする
plt.show 

以上だよw