Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 912dacf

Browse files
committed
Merge pull request matplotlib#149 from mdboom/none_interpolation
Add support for 'none' interpolation in SVG backend. Closes matplotlib#94.
2 parents af3243d + ec5344b commit 912dacf

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
689689

690690
self.writer.end('g')
691691

692-
def draw_image(self, gc, x, y, im):
692+
def option_scale_image(self):
693+
return True
694+
695+
def draw_image(self, gc, x, y, im, dx=None, dy=None, transform=None):
693696
attrib = {}
694697
clipid = self._get_clip(gc)
695698
if clipid is not None:
@@ -702,10 +705,10 @@ def draw_image(self, gc, x, y, im):
702705
if rcParams['svg.image_noscale']:
703706
trans = list(im.get_matrix())
704707
trans[5] = -trans[5]
705-
attrib['transform'] = generate_transform('matrix', tuple(trans))
708+
attrib['transform'] = generate_transform([('matrix', tuple(trans))])
706709
assert trans[1] == 0
707710
assert trans[2] == 0
708-
numrows,numcols = im.get_size()
711+
numrows, numcols = im.get_size()
709712
im.reset_matrix()
710713
im.set_interpolation(0)
711714
im.resize(numcols, numrows)
@@ -733,11 +736,19 @@ def draw_image(self, gc, x, y, im):
733736
im.flipud_out()
734737
attrib['xlink:href'] = filename
735738

736-
self.writer.element(
737-
'image',
738-
x=str(x/trans[0]), y=str((self.height-y)/trans[3]-h),
739-
width=str(w), height=str(h),
740-
attrib=attrib)
739+
if transform is None:
740+
self.writer.element(
741+
'image',
742+
x=str(x/trans[0]), y=str((self.height-y)/trans[3]-h),
743+
width=str(w), height=str(h),
744+
attrib=attrib)
745+
else:
746+
attrib['transform'] = generate_transform(
747+
[('matrix', transform.to_values())])
748+
self.writer.element(
749+
'image',
750+
x=str(x), y=str(y), width=str(dx), height=str(dy),
751+
attrib=attrib)
741752

742753
if url is not None:
743754
self.writer.end('a')

0 commit comments

Comments
 (0)