Transforming Line2D by transData + offsets on both sides

Hello there!

I’m updating the matplotlib interface for igraph and cannot quite figure out how to solve this issue. Any help would be kindly appreciated.

I create two circles as a PatchCollection, with radii in point units and offsets in data units - we want the dots to keep the same size upon zooming, and they should not become ellipses when ax.set_aspect is invoked. So far so good.

Now I’d like to draw a line that connects the circles edge to edge, without overlapping. That should hold even upon zoom, so I need some kind of transform whereby transData is applied first, then each of the two ends of the line is offset by a different vector (the left end should move a few points to the right, and vice versa for the left end of the line).

So going from this:

line_two_dots

to this (gimp edited):

line_two_dots_fixed

Can anyone suggest how to achieve this?

(notice that hiding the line behind is not enough, it really has to go edge-to-edge)

Can you post the code for your minimal example. Showing both how you get the first part, and what you’ve tried so far that doesn’t work

Thanks for the quick reply. I mean, it’s a line with two dots. The first figure you can just

ax.scatter(x, y)
ax.plot(x, y)

The second figure is the matter at hand.

I’ve tried a bunch of things including offset transforms and scaled translations. I got one version working half well by subclassing LineCollection and triggering a path recalculation inside draw but it’s messy.

Has anyone gotten this to work or a suggestion as of how to proceed?

Thank you

Why is that the case? It seems to make things far more complicated that way.

Because the immediate next need is arrows that point towards the circle - the arrowhead cannot be hidden behind the circle itself

···

On Fri, May 26, 2023, at 05:53, Elliott Sales de Andrade via Matplotlib wrote:

QuLogic https://discourse.matplotlib.org/u/qulogic
May 25

iosonofabio:
(notice that hiding the line behind is not enough, it really has to go edge-to-edge)

Why is that the case? It seems to make things far more complicated that way.

Visit Topic
https://discourse.matplotlib.org/t/transforming-line2d-by-transdata-offsets-on-both-sides/23817/4
or reply to this email to respond.

To unsubscribe from these emails, click here
https://discourse.matplotlib.org/email/unsubscribe/a851edcf1c087356df4f6057f879c0e10a05d563a2aa9de7d62396f2bf5bfbc2.