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

Commit6847119

Browse files
authored
Merge pull request#8850 from tacaswell/pdf_color_none
Pdf color none
2 parents4ec14fb +51f0705 commit6847119

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,6 +1626,13 @@ def check_gc(self, gc, fillcolor=None):
16261626

16271627
orig_alphas=getattr(gc,'_effective_alphas', (1.0,1.0))
16281628

1629+
ifgc.get_rgb()isNone:
1630+
# it should not matter what color here
1631+
# since linewidth should be 0
1632+
# unless affected by global settings in rcParams
1633+
# hence setting zero alpha just incase
1634+
gc.set_foreground((0,0,0,0),isRGBA=True)
1635+
16291636
ifgc._forced_alpha:
16301637
gc._effective_alphas= (gc._alpha,gc._alpha)
16311638
eliffillcolorisNoneorlen(fillcolor)<4:

‎lib/matplotlib/testing/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ def crop_to_same(actual_path, actual_image, expected_path, expected_image):
355355
# clip the images to the same size -- this is useful only when
356356
# comparing eps to pdf
357357
ifactual_path[-7:-4]=='eps'andexpected_path[-7:-4]=='pdf':
358-
aw,ah=actual_image.shape
359-
ew,eh=expected_image.shape
358+
aw,ah,ad=actual_image.shape
359+
ew,eh,ed=expected_image.shape
360360
actual_image=actual_image[int(aw/2-ew/2):int(
361361
aw/2+ew/2),int(ah/2-eh/2):int(ah/2+eh/2)]
362362
returnactual_image,expected_image

‎lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
_determinism_check)
2020
frommatplotlib.testing.decoratorsimportimage_comparison
2121
frommatplotlibimportdviread
22+
frommatplotlib.testing.compareimportcompare_images
2223

24+
importmatplotlibasmpl
2325

2426
needs_usetex=pytest.mark.xfail(
2527
notcheckdep_usetex(True),
@@ -193,3 +195,16 @@ def psfont(*args, **kwargs):
193195
ax.text(0.5,0.5,'hello')
194196
withtempfile.TemporaryFile()astmpfile,pytest.raises(ValueError):
195197
fig.savefig(tmpfile,format='pdf')
198+
199+
200+
@pytest.mark.style('default')
201+
deftest_pdf_savefig_when_color_is_none(tmpdir):
202+
fig,ax=plt.subplots()
203+
plt.axis('off')
204+
ax.plot(np.sin(np.linspace(-5,5,100)),'v',c='none')
205+
actual_image=tmpdir.join('figure.pdf')
206+
expected_image=tmpdir.join('figure.eps')
207+
fig.savefig(str(actual_image),format='pdf')
208+
fig.savefig(str(expected_image),format='eps')
209+
result=compare_images(str(actual_image),str(expected_image),0)
210+
assertresultisNone

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp