用折线图绘制圆
# 导入包
import matplotlib.pyplot as plt
from matplotlib.patches import Circle
import numpy as np
# 绘图
fig,ax = plt.subplots(2,2)
x=np.linspace(0,2*np.pi,500)
y1=2*np.cos(x)
y2=2*np.sin(x)
# subplot(221)
ax[0,0].plot(y1,y2,color='cornflowerblue',lw=2)
# 不懂这里为什么plot(y1,y2就能画出来圆了)
ax[0,0].set_xlim(-3,3)
ax[0,0].set_ylim(-3,3)
# subplot(222)
rectangle=ax[0,1].patch
rectangle.set_facecolor('gold')
ax[0,1].plot(y1,y2,color='cornflowerblue',lw=2)
ax[0,1].set_xlim(-3,3)
ax[0,1].set_ylim(-3,3)
ax[0,1].set_aspect('equal','box')
# x,y轴的刻度线的变化量不同,采用ax[0,1].set_aspect('equal','box')使其相同
# subplot(223)
rectangle=ax[1,0].patch
rectangle.set_facecolor('palegreen')
ax[1,0].plot(y1,y2,color='cornflowerblue',lw=2)
ax[1,0].set_aspect('equal','box')
# subplot(224) 见详解1有代码变换
rectangle=ax[1,0].patch
rectangle.set_facecolor('lightskyblue')
ax[1,1].plot(y1,y2,color='cornflowerblue',lw=2)
ax[1,1].axis([-3,3,-3,3])
ax[1,1].set_yticks(np.arange(-3,4,1))
ax[1,1].axis('equal')
# 相比(222)将刻度线的变化量进行调整,使之保持相同的增量,不进行x,y轴的坐标轴显示范围的操作
plt.subplots_adjust(left=0.1) # 详解2
plt.show()
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191212155029589.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDMwMTYyMQ==,size_16,color_FFFFFF,t_70)
详解1:
# subplot(224)
rectangle=ax[1,0].patch
rectangle.set_facecolor('lightskyblue')
ax[1,1].plot(y1,y2,color='cornflowerblue',lw=2)
ax[1,1].axis([-3,3,-3,3])
ax[1,1].set_yticks(np.arange(-3,4,1))
ax[1,1].axis(&#