New Pick Method with a simple example

you use PickBigLine. Basically, PickBigLine evaluates the

    > orthogonal distance from the selected point to the line by
    > calculating the intersection between the line you want to
    > select and a line passing through the selected point which
    > is orthogonal. Here is a modified version of PickBigLine
    > taking into account your remarks and working with Matplotlib
    > 0.82.

Hi Paul,

OK, at least now I understand what the problem is. The current Axes
picker works on line vertices and not individual segments, so if you
zoom in on a segment and click on it you may not be near any of the
vertices. There is a similar problem with picking on polygons.
Ideally, you want to iterate over all the segments in the lines and
return the minimum distance to a segment (note there is a method
matplotlib.mlab.dist_point_to_segment which computes this distance).
For polygons, you would want to implement a test of insidedness.

I thought about this when implementing the pick method but was afraid
of the case when you have lots of segments; things could get really
slow if you have a line with 10000 points unless you wrote some
special purpose extension code.

I do not think a separate "pick big line method" is needed here.
Perhaps it makes more sense to add a flag to the pick method which
either does it the correct and potentially slow way (useverts=False or
something like that) or just picks on the vertices which is fast. For
dense lines, picking on the vertices works fine, but as you note this
condition isn't always true.

    > My interests are in ray tracing in geophysics. I am
    > generating a lot of lines (thousands of) and then I need
    > after zooming to identify trajectories connecting a source
    > and a receiver . For example when I am picking a line I need
    > to know to what beam it belongs and also to what ray it
    > coresponds (two integers for instance) which is something I
    > know when I am plotting the line. I don't know how to do it
    > with the label property. It is an axes property not a line2D
    > property. If you want I can give an example of the use of
    > the tag property I add.

An example would help.

Of course, in python, you can "tag" anything you want

    ax = subplot(111)
    ax.myinitials = 'JDH'

    line, = ax.plot([1,2,3])
    line.mydata = ('Hi', 23)

So it is questionable whether adding a "tag" attribute in particular
is helpful.

JDH

John Hunter a écrit :

"Paul" == Paul Cristini <paul.cristini@...240...> writes:
           
   > you use PickBigLine. Basically, PickBigLine evaluates the
   > orthogonal distance from the selected point to the line by
   > calculating the intersection between the line you want to
   > select and a line passing through the selected point which
   > is orthogonal. Here is a modified version of PickBigLine
   > taking into account your remarks and working with Matplotlib
   > 0.82.

Hi Paul,

OK, at least now I understand what the problem is. The current Axes
picker works on line vertices and not individual segments, so if you
zoom in on a segment and click on it you may not be near any of the
vertices. There is a similar problem with picking on polygons.
Ideally, you want to iterate over all the segments in the lines and
return the minimum distance to a segment (note there is a method
matplotlib.mlab.dist_point_to_segment which computes this distance).
For polygons, you would want to implement a test of insidedness.

I thought about this when implementing the pick method but was afraid
of the case when you have lots of segments; things could get really
slow if you have a line with 10000 points unless you wrote some
special purpose extension code.

I do not think a separate "pick big line method" is needed here.
Perhaps it makes more sense to add a flag to the pick method which
either does it the correct and potentially slow way (useverts=False or
something like that) or just picks on the vertices which is fast. For
dense lines, picking on the vertices works fine, but as you note this
condition isn't always true.

   > My interests are in ray tracing in geophysics. I am
   > generating a lot of lines (thousands of) and then I need
   > after zooming to identify trajectories connecting a source
   > and a receiver . For example when I am picking a line I need
   > to know to what beam it belongs and also to what ray it
   > coresponds (two integers for instance) which is something I
   > know when I am plotting the line. I don't know how to do it
   > with the label property. It is an axes property not a line2D
   > property. If you want I can give an example of the use of
   > the tag property I add.

An example would help.

Of course, in python, you can "tag" anything you want

   ax = subplot(111)
   ax.myinitials = 'JDH'

   line, = ax.plot([1,2,3])
   line.mydata = ('Hi', 23)

So it is questionable whether adding a "tag" attribute in particular
is helpful.

JDH

-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

You're right I did some tests taking into account your remarks and it
works well. I agree the tag method is not helpfull and I can do without
it. I also agree that a separate method for picking is not needed a flag
just as you suggested will be enough. The mlab.dist_point_to_segment
provides exactly the same results as what I wrote in the PickBigLine.
Thanks a lot for your advices
Paul