Skip to content

Bug Fix For "matplotlib eventplot not shows all the binary data for big number of events" - Draft PR #30053

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

ebubekir-pulat
Copy link

@ebubekir-pulat ebubekir-pulat commented May 14, 2025

** DRAFT PULL REQUEST **

closes #20243

This PR is a fix to the bug from Issue 20243. The bug concerns events being missing in graphs outputted by eventplot, when there is insufficient space for all events, for example when linelengths=1 and there is small screen space, and over 500 events to plot.

The fix involves a simple check to whether the number of events exceeds 200, and if the snap kwargs has not been set explicitly by the eventplot caller, and if so, turns off snapping, sets 'antialiaseds' to True, and outputs a warning letting them know snapping has been turned off due to high number of events, but they can override by manually setting snapping to True. Below (Figure 1) is a screenshot showing how the fix should work.

Figure 1
image

I believe this is the appropriate fix for this issue, as Path Simplification does not appear to be the source of the bug, as shown below, where the code in Figure 2 was run, with a print statement in src/path_converters.h, after the initial if-statement in the PathSimplifier Class' vertex function, on the main branch, as shown in Figure 3. Despite the print statement, no prints were outputted into the terminal when running the code in Figure 2, as shown in the terminal output in Figure 4. This suggests that Path Simplification is not involved in the bug in #20243.

Figure 2
image

Figure 3
image

Figure 4
image

@rcomer
Copy link
Member

rcomer commented May 14, 2025

Hi @ebubekir-pulat I see you now have three draft PRs open. Do you need some help from us to get them ready for review? In general draft PRs tend to be ignored and assumed "work in progress" unless you tell us otherwise.

Thanks for your contributions!

@ebubekir-pulat
Copy link
Author

ebubekir-pulat commented May 14, 2025

Thank you @rcomer for the response. Yes, I would like some advice on how to improve my pull requests to get them ready for merging. What should I write in my pull requests to clearly show I would like feedback, criticism etc?

@rcomer
Copy link
Member

rcomer commented May 14, 2025

@ebubekir-pulat we have some guidelines here to work through, but as it says, it doesn't have to be perfect. If you are stuck on something specific, do ask. If not, mark the PR ready for review when you have got it as ready as you can.

@melissawm melissawm moved this to Waiting for author in First Time Contributors May 22, 2025
@ebubekir-pulat ebubekir-pulat marked this pull request as ready for review May 23, 2025 00:45
@ebubekir-pulat
Copy link
Author

ebubekir-pulat commented May 23, 2025

I think this fix is good to go. Is there need for any changes to the documentation?

I think some changes to eventplot-related tests in test_axes.py, and the 'test_get_font_names' test in test_font_manager.py, might need to be made.

@rcomer
Copy link
Member

rcomer commented May 28, 2025

@ebubekir-pulat have a look at the triage_tests.py script to help you review those image test failures and replace the reference images if appropriate.

The failure for test_get_font_names may just be a missing font on your system (I also get this failure locally) so I suggest to ignore it unless it also shows in the test output below.

@ebubekir-pulat
Copy link
Author

ebubekir-pulat commented Jun 5, 2025

@rcomer Here are the results we got for the 3 failing image tests in test_axes.py.

eventplot.png
image

eventplot-expected.png
image

eventplot-failed-diff.png
image

test_eventplot_defaults.png
image

test_eventplot_defaults-expected.png
image

test_eventplot_defaults-failed-diff.png
image

test_eventplot_problem_kwargs.png
image

test_eventplot_problem_kwargs-expected.png
image

test_eventplot_problem_kwargs-failed-diff.png
image

Is there a certain range of RMS in the image test failures that is acceptable, so if it is within that, we can simply replace the reference images?

@oscargus
Copy link
Member

oscargus commented Jun 5, 2025

Can you please also show the resulting images? Most likely the scaling has changed a bit for some reason, but hard to say without seeing the new images (the expected ones are in the repo, so while it helps to have them visible for reference, the new ones are more relevant).

@oscargus
Copy link
Member

oscargus commented Jun 5, 2025

And after reading the code, no, the reason is that snapping is off. As @jklymak thought that snapping can be off here, it should be good to go. But please add the new images so that one see the actual effect of this.

@ebubekir-pulat
Copy link
Author

ebubekir-pulat commented Jun 5, 2025

@oscargus Would the 'new image' for test_eventplot be 'eventplot.png' for example? If so, I have accordingly updated the above comment showing the image outputs

@oscargus
Copy link
Member

oscargus commented Jun 5, 2025

That should be the correct ones, yes!

If you copy those to the lib/matplotlib/tests/baseline_images (plus correct subdirectory test_YYY) and add them to the PR (overwrite the old ones), it should make it even simpler to compare as there are some tools for that in GitHub.

To me it seems like the new results are OK. In some situations the lines are bit blurred in the new one due to lack of snapping, but I think one can live with that. One should maybe add a note that the default has changed, but it can be discussed where that should be added. I'll ping @timhoffm as the API lead to have a say.

Edit: to summarize for Tim. If snap is not provided for eventplot, it will now default to False (and antialiasing will be turned on). There is a warning, but that should maybe be rephrased as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

matplotlib eventplot not shows all the binary data for big number of events
6 participants