Jae-Joon Lee wrote: > Hi Jason, > > I did made a similar class sometime ago and I'm attaching it just in > case. I guess it is very similar to yours but I rely on > matplolib.patches.FancyArrow class to draw the arrow head. > > The circle drawn by scatter() command should be a circle with size s > (the third argument of the scatter command) in points . It seems that > it is implemented as a unit circle centered at (0,0) with a transform > corresponding to the size s (and offset). So you may try something > like below to calculate the size of the circle in data coord. > > ax = gca() > p = scatter([0],[0], 500.) > tr = p.get_transforms()[0] + ax.transData.inverted() > x1, y1 = tr.transform_point([0,0]) > x2, y2 = tr.transform_point([1,0]) > r = abs(x2 - x1) > > p is a collection object and p.get_transforms() is a list of transforms. > Note that a circle in the canvas coordinate(?) can be an ellipse in > data coordinates. So, I guess you'd better do things in the canvas > coordinates. > > For shortening your path, if you're only concerned with a straight > line, it should be straight forward. But I guess it would a bit tricky > to do this for general bezier curves (as in the example that Alan > linked). I think (but I may be wrong) there is no universal algorithm > to find the "all" intersecting points of two bezier curves. There may > be one for between a bezier curve and a circle. And in this case where > one point is inside the circle and the other is outside, one simple > way I can think of is to recursively bisect the bezier curve (similar > to the bisect root finding).
Jae-Joon, Thank you very much. I am just finishing implementing a working version of what I wanted in my ArrowLine class; it now shortens itself by a certain number of points (assuming a line, just using a scale transformation). However, I use paths for drawing the arrowhead where you use patches. I think I like the flexibility your approach offers. Do you mind if I include your code in the GPL-licensed Sage, and extend it to do this shortening thing that I need? I still haven't decided which is ultimately better for what I need (my class or your class), but if you're willing to license your class in a compatible way, that provides a choice. Thanks, Jason ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users