diff --git a/lib/matplotlib/contour.py b/lib/matplotlib/contour.py index f6e81ebbdbc4..7678623ca40a 100644 --- a/lib/matplotlib/contour.py +++ b/lib/matplotlib/contour.py @@ -575,6 +575,9 @@ 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 is in points. + lw *= self.ax.figure.dpi / 72.0 # scale to screen coordinates + # now lw in pixels # Figure out label rotation. if inline: diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_labels_size_color.png b/lib/matplotlib/tests/baseline_images/test_contour/contour_labels_size_color.png index 7b49dd328c6a..21afe6eccab5 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_contour/contour_labels_size_color.png and b/lib/matplotlib/tests/baseline_images/test_contour/contour_labels_size_color.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.pdf b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.pdf index 2dd02c48fb5a..cbe59ab0e74c 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.pdf and b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.png b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.png index 0884343cd928..97cce15d3a1f 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.png and b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.png differ diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.svg b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.svg index 6ce04555e1b3..fb8905928bdc 100644 --- a/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.svg +++ b/lib/matplotlib/tests/baseline_images/test_contour/contour_manual_labels.svg @@ -19,242 +19,231 @@ z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +L 0 3.5 +" id="mcd7c04be3a" style="stroke:#000000;stroke-width:0.8;"/> - + + + - - - - - - - - - - - - - + - + - + + + - - - - - - - - - - + - + - + + + - + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + - + - - + + - - + + - + - + + + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +" id="DejaVuSans-36"/> - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -793,8 +414,8 @@ z - - + + diff --git a/lib/matplotlib/tests/baseline_images/test_contour/contour_test_label_transforms.png b/lib/matplotlib/tests/baseline_images/test_contour/contour_test_label_transforms.png index f5b3db8d646f..59176950533e 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_contour/contour_test_label_transforms.png and b/lib/matplotlib/tests/baseline_images/test_contour/contour_test_label_transforms.png differ diff --git a/lib/matplotlib/tests/test_contour.py b/lib/matplotlib/tests/test_contour.py index 43dd63bcc7ee..cb1838f54f4d 100644 --- a/lib/matplotlib/tests/test_contour.py +++ b/lib/matplotlib/tests/test_contour.py @@ -171,20 +171,21 @@ def test_contour_uniform_z(): assert len(record) == 1 -@image_comparison(baseline_images=['contour_manual_labels']) +@image_comparison(baseline_images=['contour_manual_labels'], + savefig_kwarg={'dpi': 200}, remove_text=True, style='mpl20') 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) cs = plt.contour(x, y, z) pts = np.array([(1.5, 3.0), (1.5, 4.4), (1.5, 6.0)]) plt.clabel(cs, manual=pts) @image_comparison(baseline_images=['contour_labels_size_color'], - extensions=['png'], remove_text=True) + extensions=['png'], remove_text=True, style='mpl20') def test_contour_labels_size_color(): x, y = np.meshgrid(np.arange(0, 10), np.arange(0, 10))