绘制半径为20,40,80的同心圆的Python程序怎么写?
要可视化吗
import numpy as np
from matplotlib import pyplot as plt
fig1=plt.figure(figsize=(6,6))
x1 = 20
x2 = 40
x3 = 80
x_1 = np.linspace(-x1, x1,num=1000)
x_2 = np.linspace(-x2, x2,num=1000)
x_3 = np.linspace(-x3, x3,num=1000)
#圆1
y_1 = np.sqrt(x1**2-x_1**2)
y_1_1 = -np.sqrt(x1**2-x_1**2)
plt.plot(x_1,y_1_1,c="b")
plt.plot(x_1,y_1,c="b")
#圆2
y_2 = np.sqrt(x2**2-x_2**2)
y_2_2 = -np.sqrt(x2**2-x_2**2)
plt.plot(x_2,y_2_2,c="g")
plt.plot(x_2,y_2,c="g")
#圆3
y_3 = np.sqrt(x3**2-x_3**2)
y_3_3 = -np.sqrt(x3**2-x_3**2)
plt.plot(x_3,y_3_3,c="r")
plt.plot(x_3,y_3,c="r")
plt.show()