1import matplotlib.pyplot as plt
2
3circle1 = plt.Circle((0, 0), 0.2, color='r')
4circle2 = plt.Circle((0.5, 0.5), 0.2, color='blue')
5circle3 = plt.Circle((1, 1), 0.2, color='g', clip_on=False)
6
7fig, ax = plt.subplots() # note we must use plt.subplots, not plt.subplot
8# (or if you have an existing figure)
9# fig = plt.gcf()
10# ax = fig.gca()
11
12ax.add_patch(circle1)
13ax.add_patch(circle2)
14ax.add_patch(circle3)
15
16fig.savefig('plotcircles.png')
17
1circle1 = plt.Circle((0, 0), 2, color='r')
2# now make a circle with no fill, which is good for hi-lighting key results
3circle2 = plt.Circle((5, 5), 0.5, color='b', fill=False)
4circle3 = plt.Circle((10, 10), 2, color='g', clip_on=False)
5
6ax = plt.gca()
7ax.cla() # clear things for fresh plot
8
9# change default range so that new circles will work
10ax.set_xlim((0, 10))
11ax.set_ylim((0, 10))
12# some data
13ax.plot(range(11), 'o', color='black')
14# key data point that we are encircling
15ax.plot((5), (5), 'o', color='y')
16
17ax.add_patch(circle1)
18ax.add_patch(circle2)
19ax.add_patch(circle3)
20fig.savefig('plotcircles2.png')
21