-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
implements best legend place holder #4536
Conversation
Nice, I'm going to try it now. Don't forget to run |
Co-authored-by: t-bltg <tf.bltg@gmail.com>
Co-authored-by: t-bltg <tf.bltg@gmail.com>
Co-authored-by: t-bltg <tf.bltg@gmail.com>
Actually most of them look weird to me, it is not what I was expecting. But now that I know those tests exist, I can check each of them before committing changes. (The histogram is case is a case apart, as the plot does not show the data series, and what I do know is based on the data series). |
The refs files are checked when running You can set Line 53 in e6a0689
See also https://docs.juliaplots.org/stable/contributing/#VisualRegressionTests. |
Co-authored-by: t-bltg <tf.bltg@gmail.com>
To quickly run an example, you can use |
Codecov ReportBase: 90.89% // Head: 90.95% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #4536 +/- ##
==========================================
+ Coverage 90.89% 90.95% +0.06%
==========================================
Files 40 40
Lines 7707 7740 +33
==========================================
+ Hits 7005 7040 +35
+ Misses 702 700 -2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Maybe we need to add some weights in the algorithm to favor the |
I'll close the PR for now to work on it further without disturbing you. |
You could also have marked it as a draft (it disables notifications ;)). |
Corresponding image PR: JuliaPlots/PlotReferenceImages.jl#142 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like @BeastyBlacksmith to comment before merging the reference images.
To me, there is no ambiguity on the automatic placement (at least on the ref images).
I just updated a comment. Nothing will change. |
I don't think there is any ambiguity. The position is deterministic, given the data set (which is a difference from the original implementation I posted on the discourse forum, which used a random sample from the data set). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be more happy if it kept :topright
in the cases where it is impossible not to overlap with data (or maybe even choose :outertopright
then).
But I like it either way. Good work!
If we could obtain the coordinates of the legend box we could try that. But I didn't find how to do it, so we are just examining the plot edges relationship with the data. We can try some different heuristics, such as summing some distances, but we would need a case where the current strategy is clearly bad. Also biased examples against any other strategy should be tested. |
I'll post the results of this different placement strategy, which does better if there is a bunch of points in one corner, but the closest overlap is in the other (should I have created a new branch? I'm still confused with this) |
Here they are: https://github.com/JuliaPlots/PlotReferenceImages.jl/pull/143/files It actually looks good, IMO. Maybe better, particularly in the scatter plots. (I'll be away for a couple of hours now) |
Thanks, merged, let's try that now. |
I've have cleaned up reference images between versions |
Should we merge ? |
Thanks @lmiq, this is a really nice contribution 🎉 . |
Implemented the best legend position placeholder: It will choose between bottomleft/right or topleft/right, depending on a sample of the data, trying to maximize the difference to the closest point. The function is fast (5-10 microseconds), and should be good enough for a guess of the best position.
Tries to address: #3399
Test it with: