matplotlib - multiple legend styles in an entry

In a current project I had to create a lot of plots. In one plot, several lines should be connected with the same text entry in the legend. To implement this I looked around the internet and stumpled upon a StackOverflow answer from 2015. It guided me to implement a solution, that worked better for my use-case.

The result can be seen in the plot below.