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 c4e75e3

Browse filesBrowse files
committed
Merged revisions 8583 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8583 | mdboom | 2010-07-27 13:26:50 -0400 (Tue, 27 Jul 2010) | 3 lines [3034778] line width arguments don't work in pcolormesh Also, support clipping paths on images in SVG backend. ........ svn path=/trunk/matplotlib/; revision=8584
2 parents e7727ad + 641ef73 commit c4e75e3
Copy full SHA for c4e75e3

File tree

Expand file treeCollapse file tree

13 files changed

+3829
-2013
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+3829
-2013
lines changed

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ def draw_quad_mesh(self, gc, master_transform, meshWidth, meshHeight,
212212

213213
if showedges:
214214
edgecolors = np.array([[0.0, 0.0, 0.0, 1.0]], np.float_)
215-
linewidths = np.array([1.0], np.float_)
215+
linewidths = np.array([gc.get_linewidth()], np.float_)
216216
else:
217217
edgecolors = facecolors
218-
linewidths = np.array([0.0], np.float_)
218+
linewidths = np.array([gc.get_linewidth()], np.float_)
219219

220220
return self.draw_path_collection(
221221
gc, master_transform, paths, [], offsets, offsetTrans, facecolors,

‎lib/matplotlib/backends/backend_svg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_svg.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,12 @@ def draw_gouraud_triangles(self, gc, triangles_array, colors_array,
389389
write('</g>\n')
390390

391391
def draw_image(self, gc, x, y, im):
392-
# MGDTODO: Support clippath here
392+
clipid = self._get_gc_clip_svg(gc)
393+
if clipid is None:
394+
clippath = ''
395+
else:
396+
clippath = 'clip-path="url(#%s)"' % clipid
397+
393398
trans = [1,0,0,1,0,0]
394399
transstr = ''
395400
if rcParams['svg.image_noscale']:
@@ -410,7 +415,9 @@ def draw_image(self, gc, x, y, im):
410415
self._svgwriter.write('<a xlink:href="%s">' % url)
411416
self._svgwriter.write (
412417
'<image x="%f" y="%f" width="%f" height="%f" '
413-
'%s xlink:href="'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, transstr)
418+
'%s %s xlink:href="' % (
419+
x/trans[0], (self.height-y)/trans[3]-h, w, h,
420+
transstr, clippath)
414421
)
415422

416423
if rcParams['svg.image_inline']:

‎lib/matplotlib/collections.py

Copy file name to clipboardExpand all lines: lib/matplotlib/collections.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,7 @@ def draw(self, renderer):
12281228

12291229
gc = renderer.new_gc()
12301230
self._set_gc_clip(gc)
1231+
gc.set_linewidth(self.get_linewidth()[0])
12311232

12321233
if self._shading == 'gouraud':
12331234
triangles, colors = self.convert_mesh_to_triangles(

‎lib/matplotlib/tests/baseline_images/test_axes/imshow.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_axes/imshow.svg
+993-987Lines changed: 993 additions & 987 deletions
Loading

‎lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_axes/imshow_clip.svg
+1,147-1,012Lines changed: 1147 additions & 1012 deletions
Loading
Binary file not shown.
Loading

‎lib/matplotlib/tests/baseline_images/test_axes/pcolormesh.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_axes/pcolormesh.svg
+1,624Lines changed: 1624 additions & 0 deletions
Loading

‎lib/matplotlib/tests/baseline_images/test_image/image_interps.svg

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/baseline_images/test_image/image_interps.svg
+16-4Lines changed: 16 additions & 4 deletions
Loading

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+33-2Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
from numpy import ma
23
import matplotlib
34
from matplotlib.testing.decorators import image_comparison, knownfailureif
45
import matplotlib.pyplot as plt
@@ -393,7 +394,7 @@ def test_imshow():
393394
ax.imshow(r)
394395
fig.savefig('imshow')
395396

396-
@image_comparison(baseline_images=['imshow_clip'])
397+
@image_comparison(baseline_images=['imshow_clip'], tol=1e-2)
397398
def test_imshow_clip():
398399
# As originally reported by Gellule Xg <gellule.xg@free.fr>
399400

@@ -438,7 +439,7 @@ def test_polycollection_joinstyle():
438439

439440
fig.savefig('polycollection_joinstyle')
440441

441-
@image_comparison(baseline_images=['fill_between_interpolate'])
442+
@image_comparison(baseline_images=['fill_between_interpolate'], tol=1e-2)
442443
def test_fill_between_interpolate():
443444
x = np.arange(0.0, 2, 0.02)
444445
y1 = np.sin(2*np.pi*x)
@@ -473,6 +474,36 @@ def test_symlog():
473474

474475
fig.savefig('symlog')
475476

477+
@image_comparison(baseline_images=['pcolormesh'])
478+
def test_pcolormesh():
479+
n = 12
480+
x = np.linspace(-1.5,1.5,n)
481+
y = np.linspace(-1.5,1.5,n*2)
482+
X,Y = np.meshgrid(x,y);
483+
Qx = np.cos(Y) - np.cos(X)
484+
Qz = np.sin(Y) + np.sin(X)
485+
Qx = (Qx + 1.1)
486+
Z = np.sqrt(X**2 + Y**2)/5;
487+
Z = (Z - Z.min()) / (Z.max() - Z.min())
488+
489+
# The color array can include masked values:
490+
Zm = ma.masked_where(np.fabs(Qz) < 0.5*np.amax(Qz), Z)
491+
492+
fig = plt.figure()
493+
ax = fig.add_subplot(121)
494+
ax.pcolormesh(Qx,Qz,Z, lw=0.5, edgecolors='k')
495+
ax.set_title('lw=0.5')
496+
ax.set_xticks([])
497+
ax.set_yticks([])
498+
499+
ax = fig.add_subplot(122)
500+
ax.pcolormesh(Qx,Qz,Z, lw=3, edgecolors='k')
501+
ax.set_title('lw=3')
502+
ax.set_xticks([])
503+
ax.set_yticks([])
504+
505+
fig.savefig('pcolormesh')
506+
476507
if __name__=='__main__':
477508
import nose
478509
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

‎lib/matplotlib/tests/test_image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_image.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_image_clip():
104104

105105
d = [[1,2],[3,4]]
106106

107-
ax.imshow(d, extent=(-pi,pi,-pi/2,pi/2))
107+
im = ax.imshow(d, extent=(-pi,pi,-pi/2,pi/2))
108108

109109
fig.savefig('image_clip')
110110

‎lib/matplotlib/tests/test_simplification.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_simplification.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_clipping():
2929
ax.set_yticks([])
3030
fig.savefig('clipping')
3131

32-
@image_comparison(baseline_images=['overflow'])
32+
@image_comparison(baseline_images=['overflow'], tol=1e-2)
3333
def test_overflow():
3434
x = np.array([1.0,2.0,3.0,2.0e5])
3535
y = np.arange(len(x))

‎src/_backend_agg.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg.cpp
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,9 +1091,9 @@ RendererAgg::draw_image(const Py::Tuple& args)
10911091
{
10921092
set_clipbox(gc.cliprect, rendererBase);
10931093
rendererBase.blend_from(pixf, 0, (int)x, (int)(height - (y + image->rowsOut)));
1094-
rendererBase.reset_clipping(true);
10951094
}
10961095

1096+
rendererBase.reset_clipping(true);
10971097
image->flipud_out(empty);
10981098

10991099
return Py::Object();
@@ -1747,7 +1747,7 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args)
17471747
Py::SeqBase<Py::Object> transforms_obj;
17481748
Py::Object edgecolors_obj;
17491749
Py::Tuple linewidths(1);
1750-
linewidths[0] = Py::Float(1.0);
1750+
linewidths[0] = Py::Float(gc.linewidth);
17511751
Py::SeqBase<Py::Object> linestyles_obj;
17521752
Py::Tuple antialiaseds(1);
17531753
antialiaseds[0] = Py::Int(antialiased ? 1 : 0);

0 commit comments

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