用python写一个代码画出一个男人抱着一个女人
时间: 2023-06-05 20:06:43 浏览: 135
好的,以下是给定的Python代码,它可以画出一个男人抱着一个女人的图像:
```
import matplotlib.pyplot as plt
# Create the figure and axes objects
fig, ax = plt.subplots()
# Draw a circle for the man's head
man_head = plt.Circle((0.5, 0.75), 0.1, color='b')
ax.add_patch(man_head)
# Draw a rectangle for the man's body
man_body = plt.Rectangle((0.45, 0.35), 0.1, 0.4, color='b')
ax.add_patch(man_body)
# Draw a circle for the woman's head
woman_head = plt.Circle((0.7, 0.5), 0.1, color='r')
ax.add_patch(woman_head)
# Draw a rectangle for the woman's body
woman_body = plt.Rectangle((0.65, 0.1), 0.1, 0.4, color='r')
ax.add_patch(woman_body)
# Draw a line connecting the man and woman
line = plt.Line2D((0.55, 0.65), (0.65, 0.5), color='k')
ax.add_line(line)
# Set the axis limits and aspect ratio
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.set_aspect('equal')
# Show the plot
plt.show()
```
阅读全文