# coding=utf-8
# !/usr/bin/env python
# __author__ = 'pipi'
# ctime 2014.10.11
# 绘制椭圆和圆形
###################################
from matplotlib.patches import Ellipse, Circle
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ell1 = Ellipse(xy = (0.0, 0.0), width = 4, height = 8, angle = 30.0, facecolor= 'yellow', alpha=0.3)
cir1 = Circle(xy = (0.0, 0.0), radius=2, alpha=0.5)
ax.add_patch(ell1)
ax.add_patch(cir1)
x, y = 0, 0
ax.plot(x, y, 'ro')
plt.axis('scaled')
# ax.set_xlim(-4, 4)
# ax.set_ylim(-4, 4)
plt.axis('equal') #changes limits of x or y axis so that equal increments of x and y have the same length
plt.show()
你可以试试,谢谢。
import matplotlib.pyplot as pltfrom matplotlib.patches import Circle
# 创建一个图形对象
fig = plt.figure()
# 循环绘制一百个同心圆
for i in range(100):
# 使用 Circle 类创建圆形,并指定半径和圆心坐标
circle = Circle(xy=(0, 0), radius=i+1)
# 使用 fig.add_subplot() 方法将圆形添加到图中
ax = fig.add_subplot(1, 1, 1)
ax.add_patch(circle)
# 调用 plt.show() 方法显示图形
plt.show()