Reputation: 383
I use scatter to plot some points. For example:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
ax.scatter([1,2, 1.5], [2, 1, 1.5])
plt.show()
Now I also want a circle with radius 0.5 around point [1.5, 1.5] in the plot. How do I do that? I know that there are edgecolors, so that I could just set them to 'none' and then to some color. But those circles then have no radius of 0.5.
Upvotes: 7
Views: 16095
Reputation: 141
To make a circle around point, you can use plt.Circle as shown below:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
ax.scatter([1,2, 1.5], [2, 1, 1.5])
cir = plt.Circle((1.5, 1.5), 0.07, color='r',fill=False)
ax.set_aspect('equal', adjustable='datalim')
ax.add_patch(cir)
plt.show()
I hope this solved your problem. And please let me know further.
Upvotes: 6