用python代码,画出二维喜羊羊头像,给出python代码
时间: 2023-11-12 11:37:49 浏览: 50
关于羊的代码
import matplotlib.pyplot as plt
import numpy as np
#定义喜羊羊轮廓
x = np.linspace(-1,1,100)
y1 = np.sqrt(1-x**2)
y2 = -np.sqrt(1-x**2)
y3 = np.array([0.2]*100)
y4 = np.array([-0.2]*100)
#画喜羊羊头像
fig, ax = plt.subplots()
ax.plot(x,y1,color='black')
ax.plot(x,y2,color='black')
ax.plot(x,y3,color='black')
ax.plot(x,y4,color='black')
ax.fill_between(x, y1, y2, where=y1>y2, facecolor='white', interpolate=True)
ax.set_aspect(1.0)
plt.show()
阅读全文