Skip to content

Commit 0d11d38

Browse files
committed
Fix origin handling when interpolation is None in SVG backend. Issue #925.
1 parent 68e7569 commit 0d11d38

File tree

5 files changed

+125
-2
lines changed

5 files changed

+125
-2
lines changed

lib/matplotlib/backends/backend_svg.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -794,11 +794,17 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
794794
attrib=attrib)
795795
else:
796796
flipped = self._make_flip_transform(transform)
797+
flipped = np.array(flipped.to_values())
798+
y = y+dy
799+
if dy > 0.0:
800+
flipped[3] *= -1.0
801+
y *= -1.0
797802
attrib[u'transform'] = generate_transform(
798-
[(u'matrix', flipped.to_values())])
803+
[(u'matrix', flipped)])
799804
self.writer.element(
800805
u'image',
801-
x=unicode(x), y=unicode(y+dy), width=unicode(dx), height=unicode(-dy),
806+
x=unicode(x), y=unicode(y),
807+
width=unicode(dx), height=unicode(abs(dy)),
802808
attrib=attrib)
803809

804810
if url is not None:
Binary file not shown.

lib/matplotlib/tests/test_image.py

+13
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ def test_imshow():
152152
ax.set_xticks([])
153153
ax.set_yticks([])
154154

155+
@image_comparison(baseline_images=['no_interpolation_origin'])
156+
def test_no_interpolation_origin():
157+
fig = plt.figure()
158+
ax = fig.add_subplot(211)
159+
ax.imshow(np.arange(100).reshape((2, 50)), origin="lower", interpolation='none')
160+
ax.set_xticks([])
161+
ax.set_yticks([])
162+
163+
ax = fig.add_subplot(212)
164+
ax.imshow(np.arange(100).reshape((2, 50)), interpolation='none')
165+
ax.set_xticks([])
166+
ax.set_yticks([])
167+
155168
if __name__=='__main__':
156169
import nose
157170
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 commit comments

Comments
 (0)