You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Spurious lines added with some manually add contour labels #27333
when run in a script that provided a manual list of contour label locations:
when locations were manually clicked:
Expected outcome
similar, but without the spurious straight lines.
Additional information
What are the conditions under which this bug happens?
happens with both "clicked" and specified manual contour labels in certain locations
seems to happen only near areas with more complex contours
interestingly, this also happens when you specify contour label locations this way on a cartopy map and the specified points are not on the projected map. however, this is not the case here.
Has this worked in earlier versions?
worked prior to 3.8
Do you know why this bug is happening?
unfortunately, no. will look into it a bit more though.
Do you have a minimal (i.e. mpl + numpy only, preferably) reproducer of this?
I know that there were some issues in 3.8.0 that seem similar at least, but I thought I fixed them for 3.8.1 in #27045. Are you sure they persist in 3.8.1?
Okay, what is happening here is that the "nearest contour" logic is picking the point along the MOVETO line (which isn't drawn), and needs to filter out results with codes=MOVETO)
Shows that the offending point lies right on the omitted line.
Blue is the 0 contour, red is the 0 contour with all "LINETO" codes in the path (After the first point), orange dot is the requested manual position for the offending contour.
@kafitzgerald I opened a draft PR that I think should solve it, if you could to run it through the more intense gauntlet to make sure it fully resolves the issue, that would be appreciated.
I intend to write an ever further pared-down test case and add a unit test prior to getting it merged, but I thought I'd get the code out there first.
I'd have gotten back sooner, but was struggling a bit with my dev env. For whatever reason my editable install of matplotlib wasn't working. Got a regular install to work though with the fix.
And it works great on the larger cases I had (both with specified label locations and manual clicks).
Activity
ksunden commentedon Nov 16, 2023
Do you have a minimal (i.e. mpl + numpy only, preferably) reproducer of this?
I know that there were some issues in 3.8.0 that seem similar at least, but I thought I fixed them for 3.8.1 in #27045. Are you sure they persist in 3.8.1?
kafitzgerald commentedon Nov 16, 2023
Sorry about that.
Here you go:
There were some similar issues in maptlotlib 3.8 that seem to have cleared up now, but this is with 3.8.1
ksunden commentedon Nov 16, 2023
Okay, what is happening here is that the "nearest contour" logic is picking the point along the
MOVETOline (which isn't drawn), and needs to filter out results withcodes=MOVETO)The above with a few things drawn:
Shows that the offending point lies right on the omitted line.
Blue is the 0 contour, red is the 0 contour with all "LINETO" codes in the path (After the first point), orange dot is the requested manual position for the offending contour.
Should be relatively easy to fix, I think...
Omit MOVETO lines from nearest contour logic
ksunden commentedon Nov 16, 2023
@kafitzgerald I opened a draft PR that I think should solve it, if you could to run it through the more intense gauntlet to make sure it fully resolves the issue, that would be appreciated.
I intend to write an ever further pared-down test case and add a unit test prior to getting it merged, but I thought I'd get the code out there first.
Omit MOVETO lines from nearest contour logic
kafitzgerald commentedon Nov 16, 2023
Thanks!
I'd have gotten back sooner, but was struggling a bit with my dev env. For whatever reason my editable install of matplotlib wasn't working. Got a regular install to work though with the fix.
And it works great on the larger cases I had (both with specified label locations and manual clicks).
Thanks for getting this sorted so quickly!