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

MNE Report: Add Events produces cut-off plots. Can we do better? #12835

Open
sappelhoff opened this issue Sep 9, 2024 · 3 comments
Open

MNE Report: Add Events produces cut-off plots. Can we do better? #12835

sappelhoff opened this issue Sep 9, 2024 · 3 comments

Comments

@sappelhoff
Copy link
Member

For example, look at this screenshot, from a report where an Events section was added through report.add_events:

image

☝️ The plot is "cut off" in the legend box, both in terms of height and width.

Furthermore, the y-axis ticklabels are very tightly squashed together

If I want to get the non-cutoff version of this plot, then I cannot currently use report.add_events.

I need to replicate the plot myself using plot_events, setting a proper figure size, saving the plot using bbox_inches="tight", and then adding the file with add_image, which is a bit inconvenient.

Would it be reasonable to allow for a bit more customization on how much space report.add_events may reserve for the plot? So that I could also produce plots that are not cut-off with the easier add_events workflow?

@larsoner
Copy link
Member

larsoner commented Sep 9, 2024

I think there are a couple of things we could do.

My first thought was to switch plot_events to use the constrained layout engine. It's almost always better about spacing. This won't fix the problem but might make it a little better, and it's something we should probably do anyway.

Next would be, for reports in add_events, I suggest we plot the events (probably starting from plot_events) but remove the legend, add the legend-less plot, and then separately add a legend maybe below the plot, ideally in some nice way in HTML. Reports are HTML, we should take advantage of that by using stuff like overflow scrolling for cases like this where we don't know if there will be one or hundreds of events.

@sappelhoff
Copy link
Member Author

My first thought was to switch plot_events to use the constrained layout engine. It's almost always better about spacing. This won't fix the problem but might make it a little better, and it's something we should probably do anyway.

In the hope of a low hanging fruit, I just looked into that but found that we are already using "constrained layout". See:

fig = plt.figure(layout="constrained")

or did you have something else in mind?

@larsoner
Copy link
Member

or did you have something else in mind?

Nope that's what I had in mind, just didn't look at the code 🤦

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