Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.9 kB
0
Indexable
Never
import matplotlib.pyplot as plt

# Создаем фигуру и оси
fig, ax = plt.subplots()

# Нарисуем голову кота
head = plt.Circle((0.5, 0.5), 0.25, color='gray')
ax.add_patch(head)

# Нарисуем уши
left_ear = plt.Polygon([[0.3, 0.65], [0.35, 0.7], [0.4, 0.65]], color='gray')
right_ear = plt.Polygon([[0.6, 0.65], [0.65, 0.7], [0.7, 0.65]], color='gray')
ax.add_patch(left_ear)
ax.add_patch(right_ear)

# Нарисуем глаза
left_eye = plt.Circle((0.42, 0.5), 0.04, color='white')
right_eye = plt.Circle((0.58, 0.5), 0.04, color='white')
left_pupil = plt.Circle((0.42, 0.5), 0.015, color='black')
right_pupil = plt.Circle((0.58, 0.5), 0.015, color='black')
ax.add_patch(left_eye)
ax.add_patch(right_eye)
ax.add_patch(left_pupil)
ax.add_patch(right_pupil)

# Нарисуем нос и рот
nose = plt.Polygon([[0.5, 0.48], [0.47, 0.45], [0.53, 0.45]], color='black')
mouth = plt.Polygon([[0.47, 0.43], [0.53, 0.43], [0.5, 0.4]], color='black')
ax.add_patch(nose)
ax.add_patch(mouth)

# Нарисуем усы
left_whiskers = plt.Polygon([[0.45, 0.48], [0.42, 0.46], [0.42, 0.5]], color='black')
right_whiskers = plt.Polygon([[0.55, 0.48], [0.58, 0.46], [0.58, 0.5]], color='black')
ax.add_patch(left_whiskers)
ax.add_patch(right_whiskers)

# Нарисуем тело
body = plt.Rectangle((0.25, 0.3), 0.5, 0.3, color='gray')
ax.add_patch(body)

# Нарисуем ноги
left_leg = plt.Rectangle((0.3, 0), 0.1, 0.3, color='gray')
right_leg = plt.Rectangle((0.6, 0), 0.1, 0.3, color='gray')
ax.add_patch(left_leg)
ax.add_patch(right_leg)

# Нарисуем хвост
tail = plt.Polygon([[0.25, 0.2], [0.2, 0.25], [0.2, 0.1]], color='gray')
ax.add_patch(tail)

# Настроим оси и фигуру
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.axis('off')
plt.axis('scaled')

# Покажем изображение
plt.show()
Leave a Comment