Suggestion On Handling Plots

Hello NG,

    in my app, I plot the position of some oil wells
represented by dots in a x-y plot. The coordinates of the positions are
integers. I use the command:

myaxes.plot(xc, yc, "ko")

where xc, yc
are the wells' coordinates. After some calculations, I would like to do
these 2 things in the most *efficient* or *intelligent* way:

Depending on the value of a certain parameter, every well (dot) should
have a color (there are only 5 colors that a well may assume). For
example, if this parameter has a value less than 0.1, a well is painted
green, if it has a value greater than 0.1 but smaller than 1, a well is
painted blue and so on. At the moment, the only way I can think about
to implement such a thing is to do:

for ii in xrange(len(xc)):
axdata.plot([xc[i]], [yc[i]], 'ko')

which means defining a new Lines2D
object for every well. Next, it is easier to assign a different colour
to each well.

2) When the user presses the mouse "near" a well, I
would like to be able to:
a) Verify that the mouse click was "really"
near a well and not somewhere else, where there are no wells;
b) If a)
is True, retrieving which wells was clicked (which Lines2D was

At the moment, using the plot command: = myaxes.plot
(xc, yc, "ko")

I do these steps:

def mouse_press(self, event):

        # Check if the click is inside the axes
        if event.inaxes
is None:

        xvalue, yvalue = event.xdata,

        # Round to integer the click coordinates
xc, yc = int(round(xvalue)), int(round(yvalue))
        # get
xdata and ydata for all the wells
        xdata =[0][0].
        ydata =[0][0].get_ydata()
if xc in xdata:
            # find which wells have X coordinates
equals to xc
            indxs = [x[0] for x in enumerate(xdata) if x
[1] == xc]

            if yc in ydata:
                # find which
wells have Y coordinates equals to yc
                indys = [x[0] for
x in enumerate(ydata) if x[1] == yc]

                lenx = len(indxs)
                leny = len(indys)

                # create 2 lists
that can be compared in length

                if lenx < leny:
elif leny < lenx:

                tmp =
                # find the intersections
between the 2 lists
                for xcoord in indxs:
                    if xcoord in indys:
                # ==>
The click matches the well if len(tmp) > 0
                if len(tmp)


                    ind = tmp[0]
                    # get
wellnames from other sources
                    currentwell = self.

Thank you for every suggestion. Great work with