Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 88e5aae

Browse filesBrowse files
committed
Merge pull request #925 from mdboom/svg-image-origin
Cannot save image data (imshow) as SVG with interpolation='none'
2 parents 68e7569 + 0d11d38 commit 88e5aae
Copy full SHA for 88e5aae

File tree

Expand file treeCollapse file tree

5 files changed

+125
-2
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+125
-2
lines changed

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+8-2Lines changed: 8 additions & 2 deletions
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.
Loading
+104Lines changed: 104 additions & 0 deletions
Loading

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+13Lines changed: 13 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.