8000 Fix #3790. Correctly scale quadmesh linewidth to dpi in Agg backend. · matplotlib/matplotlib@27186be · GitHub
[go: up one dir, main page]

Skip to content

Commit 27186be

Browse files
committed
Fix #3790. Correctly scale quadmesh linewidth to dpi in Agg backend.
1 parent 8ca8a2c commit 27186be

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed
Loading

lib/matplotlib/tests/test_agg.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import io
77
import os
88

9+
import numpy as np
910
from numpy.testing import assert_array_almost_equal
1011

12+
from matplotlib import pyplot as plt
1113
from matplotlib.image import imread
1214
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
1315
from matplotlib.figure import Figure
14-
from matplotlib.testing.decorators import cleanup
16+
from matplotlib.testing.decorators import image_comparison, cleanup
1517

1618

1719
@cleanup
@@ -47,6 +49,20 @@ def test_repeated_save_with_alpha():
4749
decimal=3)
4850

4951

52+
@image_comparison(baseline_images=['quadmesh_linewidth'],
53+
remove_text=True,
54+
extensions=['png'],
55+
savefig_kwarg={'dpi': 400})
56+
def test_quadmesh_linewidth():
57+
fig = plt.figure(figsize=(1, 5))
58+
fig.add_subplot(111)
59+
np.random.seed(0)
60+
r = np.random.random((4, 4))
61+
plt.contourf(r, interpolation="nearest", extend="both")
62+
cb = plt.colorbar()
63+
cb.solids.set_edgecolor("face")
64+
65+
5066
def report_memory(i):
5167
pid = os.getpid()
5268
a2 = os.popen('ps -p %d -o rss,sz' % pid).readlines()

src/_backend_agg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,7 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args)
19251925

19261926
Py::Object transforms_obj = Py::List(0);
19271927
Py::Tuple linewidths(1);
1928-
linewidths[0] = Py::Float(gc.linewidth);
1928+
linewidths[0] = Py::Float(gc.linewidth * 72.0 / dpi);
19291929
Py::SeqBase<Py::Object> linestyles_obj;
19301930
Py::Tuple antialiaseds(1);
19311931
antialiaseds[0] = Py::Int(antialiased ? 1 : 0);

0 commit comments

Comments
 (0)
0