Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitc4e75e3

Browse 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 parentse7727ad +641ef73 commitc4e75e3

File tree

13 files changed

+3829
-2013
lines changed

13 files changed

+3829
-2013
lines changed

‎lib/matplotlib/backend_bases.py

Lines 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
ifshowedges:
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
returnself.draw_path_collection(
221221
gc,master_transform,paths, [],offsets,offsetTrans,facecolors,

‎lib/matplotlib/backends/backend_svg.py

Lines 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
defdraw_image(self,gc,x,y,im):
392-
# MGDTODO: Support clippath here
392+
clipid=self._get_gc_clip_svg(gc)
393+
ifclipidisNone:
394+
clippath=''
395+
else:
396+
clippath='clip-path="url(#%s)"'%clipid
397+
393398
trans= [1,0,0,1,0,0]
394399
transstr=''
395400
ifrcParams['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
ifrcParams['svg.image_inline']:

‎lib/matplotlib/collections.py

Lines 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
ifself._shading=='gouraud':
12331234
triangles,colors=self.convert_mesh_to_triangles(

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

Lines changed: 993 additions & 987 deletions
Loading

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

Lines changed: 1147 additions & 1012 deletions
Loading
Binary file not shown.

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

Lines changed: 1624 additions & 0 deletions
Loading

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

Lines changed: 16 additions & 4 deletions
Loading

‎lib/matplotlib/tests/test_axes.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
importnumpyasnp
2+
fromnumpyimportma
23
importmatplotlib
34
frommatplotlib.testing.decoratorsimportimage_comparison,knownfailureif
45
importmatplotlib.pyplotasplt
@@ -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
deftest_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
deftest_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+
deftest_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
importnose
478509
nose.runmodule(argv=['-s','--with-doctest'],exit=False)

‎lib/matplotlib/tests/test_image.py

Lines 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

Lines 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
deftest_overflow():
3434
x=np.array([1.0,2.0,3.0,2.0e5])
3535
y=np.arange(len(x))

‎src/_backend_agg.cpp

Lines 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
returnPy::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::Tuplelinewidths(1);
1750-
linewidths[0] =Py::Float(1.0);
1750+
linewidths[0] =Py::Float(gc.linewidth);
17511751
Py::SeqBase<Py::Object> linestyles_obj;
17521752
Py::Tupleantialiaseds(1);
17531753
antialiaseds[0] =Py::Int(antialiased ?1 :0);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp