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 5a88d93

Browse filesBrowse files
committed
Merge pull request #1674 from dmcdougall/fix_svg_flip
Fix SVG flip when svg.image_noscale is True
2 parents 38e4d00 + 8c25664 commit 5a88d93
Copy full SHA for 5a88d93

File tree

Expand file treeCollapse file tree

5 files changed

+220
-0
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+220
-0
lines changed

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,12 @@ def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
743743
self.writer.start(u'g', attrib={u'clip-path': u'url(#%s)' % clipid})
744744

745745
trans = [1,0,0,1,0,0]
746+
h,w = im.get_size_out()
746747
if rcParams['svg.image_noscale']:
747748
trans = list(im.get_matrix())
748749
trans[5] = -trans[5]
750+
trans[3] = -trans[3]
751+
y += h
749752
attrib[u'transform'] = generate_transform([(u'matrix', tuple(trans))])
750753
assert trans[1] == 0
751754
assert trans[2] == 0
Binary file not shown.
Loading
+206Lines changed: 206 additions & 0 deletions
Loading

‎lib/matplotlib/tests/test_backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_svg.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from io import BytesIO
66
import xml.parsers.expat
77
from matplotlib.testing.decorators import knownfailureif, cleanup
8+
from matplotlib.testing.decorators import image_comparison
89

910
@cleanup
1011
def test_visibility():
@@ -30,3 +31,13 @@ def test_visibility():
3031

3132
parser = xml.parsers.expat.ParserCreate()
3233
parser.Parse(buf) # this will raise ExpatError if the svg is invalid
34+
35+
@image_comparison(baseline_images=['noscale'], remove_text=True)
36+
def test_noscale():
37+
X, Y = np.meshgrid(np.arange(-5, 5, 1), np.arange(-5, 5, 1))
38+
Z = np.sin(Y**2)
39+
40+
fig = plt.figure()
41+
ax = fig.add_subplot(1, 1, 1)
42+
ax.imshow(Z, cmap='gray')
43+
plt.rcParams['svg.image_noscale'] = True

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.