lesson 24
fig,axes = plt.subplots(ncols =2, nrows=2)
ax1, ax2, ax3,ax4 = axes.ravel()
x = np.random.normal(size=100)
y = np.random.normal(size=100)
ax1.plot(x,y,'o')
x=np.arange(0,10)
y=np.arange(0,10)
ncolors=len(plt.rcParams['axes.color_cycle'])
shift = np.linspace(0,10,ncolors)
for s in shift:
ax2.plot(x,y+s,"-")
x=np.arange(5)
y1,y2,y3=np.random.randint(1,25,size =(3,5))
width =0.25
ax3.bar(x,y1,width)
ax3.bar(x+width,y2,width,color=plt.rcParams['axes.color_cycle'][1])
ax3.bar(x+width*2,y3,width,color=plt.rcParams['axes.color_cycle'][2])
for i, color in enumerate(plt.rcParams['axes.color_cycle']):
xy=np.random.normal(size=2)
ax4.add_patch(plt.Circle(xy,radius =0.3,color= color))
ax4.axis('equal')
plt.style.use('fivethirtyeight')
plt.show()
style:ggplot,fivethirtyeight, dmh, grayscale,dark_background
lesson 25 极坐标
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()
r=np.empty(5)
r.fill(5)
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()
r=np.empty(9)
r.fill(5)
pi_two=np.pi*2/8
theta =[0,pi_two, pi_two*2,3*pi_two,4*pi_two,pi_two*5, pi_two*6,pi_two*7,pi_two*8]
ax=plt.subplot(111, projection ='polar')
ax.plot(theta, r, color ='r',linewidth=3)
ax.grid(True)
plt.show()