-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
[Bug]: Spurious lines added with some manually add contour labels #27333
Comments
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? |
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 |
Okay, what is happening here is that the "nearest contour" logic is picking the point along the The above with a few things drawn: path = contours.get_paths()[2]
fullpath = path.deepcopy()
fullpath.codes[1:] = 2
plt.gca().add_artist(mpatches.PathPatch(path, facecolor="none", edgecolor="C0", lw=4))
plt.gca().add_artist(mpatches.PathPatch(fullpath, facecolor="none", edgecolor="C3", lw=2))
plt.plot([-72], [22500], "C1o") 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... |
@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. |
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! |
Bug summary
With Matplotlib 3.8+ I'm seeing spurious lines that get added with manually labeled contours via
clabel
.It seems to only happen in locations where the contours are more complex or near those areas, but I haven't been able to track down why this happens.
Code for reproduction
Actual outcome
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?
Has this worked in earlier versions?
Do you know why this bug is happening?
Operating system
OS/X
Matplotlib Version
3.8.1
Matplotlib Backend
MacOSX
Python version
Python 3.11.6
Jupyter version
4.0.8
Installation
conda
The text was updated successfully, but these errors were encountered: