|
From: Jae-Joon L. <lee...@gm...> - 2008-08-22 21:43:06
|
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). Regards, -JJ On Fri, Aug 22, 2008 at 12:15 PM, Alan G Isaac <ai...@am...> wrote: > Jason Grout wrote: >> The other problem is a more serious problem for me: how do >> I shorten the line so that it goes between the boundaries >> of the circle instead of the centers, especially when the >> circles are constructed in a scatter plot. > > Some years back I briefly tried to think about arrows and > I found it trickier than expected. Note that some famous > software clearly does arrows wrong. (E.g., gnuplot, at > least last I checked.) > > Example: you have decided that you want to draw to the edge > of a point, but a) is that right and b) can it be reasonably > implemented? > > a) One might well argue in many applications that the arrow > tip should go to the center of the circle. > > b) I'm not sure. > > But surely somebody out there will offer some great clues. > Perhaps along the line of graphviz: > http://www.graphviz.org/Gallery/directed/fsm.html > > Really this is not an answer to your questions ... > > Cheers, > Alan Isaac > > > > ------------------------------------------------------------------------- > 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 > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |