1、极坐标
import matplotlib.pyplot as plt
import numpy as np
--以上图形
r=np.arange(1,6,1)
theta=[0,np.pi/2,np.pi,3*np.pi/2,2*np.pi]
ax=plt.subplot(111,projection='polar')
ax.plot(theta,r,color='r',linewidth=3)
ax.grid(True)
plt.show()
--生成正方形(5个数据点,起始点重合)
r=np.empty(5)
r.fill(5)
ax=plt.subplot(111,projection='polar')
ax.plot(theta,r,color='r',linewidth=3)
ax.grid(True)
plt.show()
--八边形
r=np.empty(9)
r.fill(5)
pi_two=np.pi*2
theta=[0,pi_two/8,2*pi_two/8,3*pi_two/8,4*pi_two/8,5*pi_two/8,6*pi_two/8,7*pi_two/8,8*]
2、函数积分图
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.patches import Polygon
def func(x):
return -(x-2)*(x-8)+40
x=np.linspace(0,10)
y=func(x)
fig, ax=plt.subplots()
plt.plot(x,y,'r',linewidth=1)
a=2
b=9
ax.set_xticks([a,b])
ax.set_yricks([])
ax.set_xtickslabel