0

I have an image and I'd like to draw a representation of a graph over it. Edges are supposed to be two-colour lines where each color will represent one out of two properties of an edge.

I tried to draw two lines and translate them but there are cases where they overlap:

tr = ...
plt.plot([x1 - tr, x2 - tr], [y1 - tr, y2 - tr], linewidth=...)
plt.plot([x1 + tr, x2 + tr], [y1 + tr, y2 + tr], linewidth=...)

My question is: is there any smart way, to achieve this? Maybe is it possible with some patch?

Changing a library would be problematic here and I would like to keep matplotlib.


Note: line should have two colours like this

rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

not like this:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrrrrrrrr
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbrrrrrrrrrrrrrrrrrrrrrrrrrrr
asikorski
  • 882
  • 6
  • 20
  • 2
    Is the line mostly horizontal? Then you can add a small offset in the vertical direction. For a consistent offset, however, one would need something like [this solution](https://stackoverflow.com/questions/42165631/in-matplotlib-how-can-i-plot-a-multi-colored-line-like-a-rainbow/42190453#42190453). – ImportanceOfBeingErnest Aug 26 '19 at 19:37
  • Thanks for the link, helped me a lot! – asikorski Aug 26 '19 at 20:43

0 Answers0