I have created an array of Circle patches in Matplotlib. I need to get a list of the centers of these circle patches, for some computation.
On the documentation page of the circle patch (see matplotlib.patches.Circle on this page) , there don't seem to be any methods for extracting the center of the circle say as in mycircle.get_center. They have one for the radius, but not for the center. Any suggestions?
EDIT:
Here is some code. Basically, what I want to do is to create an interactive app in which the user clicks some disks with the mouse onto the screen. The only constraint on positioning these disks, is that they should all be disjoint. So when the user tries to insert a disk with a mouse click, I want to check if the new disk intersects the already inputted disks.
I am storing all the circle patches in an array called disk_arrangement.
Sure, I could create a separate array recording the centers, to do my job,
but that seems ugly. That's why I hope Matplotlib as a method to extract the center of a given circle-patch
def place_disk(event, disk_arrangement=[] ):
def is_inside_an_existing_disk(center_x, center_y):
if disk_arrangement != []:
for existing_disk in disk_arrangement:
if existing_disk.contains(event): #### How to do this????
return True
return False
if event.name == 'button_press_event' and \
event.dblclick == True and \
event.xdata != None and \
event.ydata != None and \
is_inside_an_existing_disk(event.xdata,event.ydata) == False :
cursor_circle = mpl.patches.Circle((event.xdata,
event.ydata),
radius=0.3,
facecolor= 'green')
disk_arrangement.append(cursor_circle)
ax.add_patch(cursor_circle)
fig.canvas.draw()
I am using Python 2.7.11 on Ubuntu 14.04