Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AbcAeffchen opened this issue Jul 3, 2023 · 2 comments
Open
Assignees

Comments

@AbcAeffchen
Copy link
Contributor

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.

@goat1000 goat1000 self-assigned this Jul 5, 2023
@goat1000
Copy link
Owner

goat1000 commented Jul 5, 2023

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.

@AbcAeffchen
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants