Skip to content

FIX: clabel manual spacing was incorrect #9989

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

Merged
merged 2 commits into from
Dec 14, 2017

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Dec 12, 2017

PR Summary

Fixes #9988. This fails some tests, but I'd argue it fails them correctly. Certainly the situation in #9988 is not acceptable.

The tests weren't catching this error because the test figure dpi is 72, so the tests look OK.

Before

figure_1-2

After

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant

@@ -177,7 +177,7 @@ def test_contour_manual_labels():
x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))
z = np.max(np.dstack([abs(x), abs(y)]), 2)

plt.figure(figsize=(6, 2))
plt.figure(figsize=(6, 2), dpi=200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't this make the test images bigger?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm, I think because the printed version doesn't care about figure dpi? There must be a way to change the test image dpi.... I'll check Thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How big size wise is the new image? Would we get the same effect going down?

@tacaswell
Copy link
Member

While you are regenerating the manual contour label test images can you also remove the text?

@jklymak
Copy link
Member Author

jklymak commented Dec 13, 2017

@tacaswell Is this really the best test to remove text?

@jklymak jklymak force-pushed the Fix-clabel-manual-space branch from d9ea329 to 3901966 Compare December 13, 2017 02:05
@@ -575,6 +575,7 @@ def add_label_near(self, x, y, inline=True, inline_spacing=5,
# Get label width for rotating labels and breaking contours
lw = self.get_label_width(self.labelLevelList[lmin],
self.labelFmt, self.labelFontSizeList[lmin])
lw *= self.ax.figure.dpi / 72.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about units?

From the conversion we are getting pts out of the get_label_width and calc_label_rot_and_inline is expecting pixels (and the doc strings seem to agree).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied the same line in the vanilla label below. I’ll readily admit I don’t understand why this stuff is all such a mess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because implicit units are hard 😈 and we used to default to 80dpi on the screen so subtle things like this are easy to miss.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I get it now. Its a little funny this uses the heuristic of 0.6 * fontsize * len(str) to get the width. I thought we had better ways to do that, but maybe we pre-draw first to do that. Anyway, that can be for a future day...

@tacaswell
Copy link
Member

The text will only pull off the tick labels, the contour labels will still be there. The less places we have the tick labels the less our exposure to the freetype issues are.

@tacaswell
Copy link
Member

Sorry to keep asking you to re-re-generate the images. Moving them to the 'mpl20' style would also be good (remove jet!).

@jklymak
Copy link
Member Author

jklymak commented Dec 13, 2017

Ok hang on if I remove jet then I have to redo all the images. Did you want that? I can easily remove the other text decorations.

@jklymak jklymak force-pushed the Fix-clabel-manual-space branch from 3901966 to 934b936 Compare December 13, 2017 03:15
@tacaswell
Copy link
Member

Just re-do the ones you have already touched. It isn't a huge deal either way, but we will eventually want to move away from 'classic' for the tests.

@jklymak jklymak force-pushed the Fix-clabel-manual-space branch from 934b936 to 815601d Compare December 13, 2017 03:24
@jklymak
Copy link
Member Author

jklymak commented Dec 13, 2017

Yes, sorry, I thought it was done on a per-file basis, but I figured out how to do it per-test

@dstansby dstansby merged commit 49d5ced into matplotlib:master Dec 14, 2017
@QuLogic QuLogic modified the milestones: needs sorting, v2.2.0 Feb 12, 2018
@jklymak jklymak deleted the Fix-clabel-manual-space branch March 5, 2019 16:10
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

Successfully merging this pull request may close these issues.

Contours are not removed correctly when using clabel with manual
4 participants