goat1000/SVGGraph

Dash pattern of line plots seems not to be reflected in the legend

Opened this issue · 2 comments

I have a MultiLinePlot with a total of 9 line (3 blue, 3 green, 3 red). On top of the colors I use 3 dash patterns to distinguish between the lines of same color. However, the dash pattern is not reflected in the legend. It only displays the marker + a full line of the respective color for each entry.

Maybe I'm missing a setting? If not, this seems to be a missing feature or even a bug.

I also would like an option for the legend to display dash patterns without color in addition to the colored lines. This way the legend could be shortened by displaying each color and each dash pattern only once instead of each combination. This could also be extended to markers.

Just as an idea, being able to define a fully custom legend (instead of having it partially generated from the plot) would probably the easiest way to support such more complex legends.

I've tested it here and it appears to be working. Maybe the dashes are not showing because the legend entry is not big enough, the legend_entry_width option should help with that.

I think I understand what you want to do with the legend and separate dash patterns/colours, but there is no easy way to do that at the moment. I'll add it to my list of things to think about.

Ah, thanks a lot. This was the issue why I didn't see the dash pattern at all.

However, not that I can see it. The issue shifted somewhat: The way the legend is generated (it seems) is beginning from the left, the dash pattern is drawn as long as the width of the legend entry is and then the marker is placed in the middle. If you use multiple dash patterns with varying length the placement of the marker can obscure the pattern. E.g. the top shows a solid line, the middle has the pattern 2,2,6,2, and the last has the pattern 2,2,2,2,6,2 but could also be 2,2.

Screenshot from 2023-07-05 15-19-21

Since the two patterns do not have the same length, it is hard to find a good entry with such that the pattern can be recognized, while keeping it reasonable small.

I'm not sure if there is a better strategy to draw the legend entries. Maybe drawing the full pattern once, then the marker at the end and then a solid line just long enough that it can be seen exiting the marker. Align all entries at the marker? Just an idea.

As for the custom legend, I want to add an example generated with mathplotlib.
Screenshot from 2023-07-05 14-19-12