Hi all,
I have a plot of data that I am enabling
the user to interact with. That is, I want them to be able to pick a
point, and then have a new plot pop up in a different figure showing more info
about that point.
So, looking through the manual and the
tutorial I have taken the code from one of the examples and am trying to modify
it to work for my needs. Here’s what I have so far:
field = arrange(-1,1.25,0.25)
CA = cellArray() # this is an object
defined elsewhere.
Ij = # a list of 2d arrays of data
def state_picker(line, mouseevent):
if
mouseevent.xdata is None:
return
False, dict()
xdata
= line.get_xdata()
ydata
= line.get_ydata()
maxd
= 0.1
d
= nx.sqrt((xdata - mouseevent.xdata)**2. + (ydata - mouseevent.ydata)**2.)
ind = nx.nonzero(nx.less_equal(d,
maxd))
if
len(ind):
out
= dict(ind=ind)
return
True, out
else:
return
False, dict()
def onpick2(event,cellArray,Ij):
Ij
= Ij[event.ind] # chose the list element from Ij corresponds to the point
selected by the user
cellArray.plot('flux',inputIj=Ij)
the cellArray object has its own plot method that requires these two
arguments
fig = figure()
ax1 = fig.add_subplot(111)
ax1.set_title(‘Energy States vs. Applied
Flux per cell’)
for i in range(len(field)):
···
#
energy is a list of arrays of different length
ax1.plot(field[i]*ones(len(energy[i])),energy[i],'.b',
picker = state_picker)
ax1.set_xlim(-1.1,1.1)
ax1.set_xlabel(‘Applied Flux per cell’)
ax1.set_ylabel(‘Array Energy (Ej)’)
fig.canvas.mpl_connect(‘pick_event’,
onpick2)
show()
The problem I’m having is that I can’t
seem to pass extra arguments to either state_picker or onpick2. Can I?
thanks for your help,
trevis
Trevis Crane
Postdoctoral Research Assoc.
Department of Physics
University of Ilinois
1110 W. Green St.
Urbana, IL 61801
p: 217-244-8652
f: 217-244-2278
e: tcrane@…1315…