Spring-like linestyle

Is it possible for me to have my own custom linestyle? Specifically, what I need is a spring-like zig-zaggy line. Anyone know how I might achieve that?

Hatches + a custom path might do the trick:

If you provide an example, might be able to suggest something simpler.

Hi Hanna, I don’t have an example yet, because I’m still not sure how to go about this.

I think I should’ve explained what I actually want: a network of points with the connections being spring-like.

I was initially thinking of making two lists X, Y, so that they may be passed to plot() to have every connected pair have a line between them.

But now I’m wondering if a quiver() would be better. Also because I need the connecting springs to be coloured based on some criterion.

So for this purpose, can I create a custom line or arrow style to pass to it?

I suggest looking at LineCollecition (https://matplotlib.org/api/collections_api.html#matplotlib.collections ). You can set up a path for the zig-zag shape you want and make use of the color mapping to set the color.

Depending on how far down the rabbit hole you want to go looking at https://github.com/networkx/grave might provide some interesting inspiration.