I was playing around with matplotlib, created a plot that allows users to add nodes (axis is set off as it’s going to be used for graph data structuer purposes, hence don’t want the y-x axis, is there another way to hide them as well?).
Basically the program below allows person press the ‘n’ button, and then can click on any point on the plot and a small circular marker will appear.
I have two questions:
You will notice that during the first 2 marker inputs, the plot rescales it self. I don’t really know why that’s happening, any idea?
Is it possible to disallow users of creating to marker points ontop of each other, so that no markers will overlap
(even if the edges)?
from pylab import *
from matplotlib.widgets import *
fig = plt.figure()
ax = fig.add_subplot(111)
cid = None
"""docstring for onClick""" ax.plot([event.xdata], [event.ydata], 'bo', picker=5, markersize=15) draw() fig.canvas.mpl_disconnect(cid)
"""docstring for onPick""" artist = event.artist artist.set_color('r') draw()
"""docstring for press""" if event.key=="n": global cid fig.canvas.mpl_disconnect(cid) cid =