You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Inconsistent behavior for savefig.facecolor + savefig.transparent depending on output format #9921
Setting both savefig.facecolor and savefig.transparent behaves differently depending on whether the image is saved as jpeg or png.
Code for reproduction
modified from test_image.test_jpeg_alpha
frompylabimport*rcdefaults()
plt.figure(figsize=(1, 1), dpi=300)
# Create an image that is all black, with a gradient from 0-1 in# the alpha channel from left to right.im=np.zeros((300, 300, 4), dtype=float)
im[..., 3] =np.linspace(0.0, 1.0, 300)
plt.figimage(im)
withrc_context({'savefig.facecolor': 'red', 'savefig.transparent': True}):
plt.savefig("/tmp/test.jpg")
plt.savefig("/tmp/test.png")
Actual outcome
test.png
test.jpg
Expected outcome
Some consistent behavior across formats (the fact that jpeg cannot represent transparency should not prevent either both files to have a red background or both files not to have a red background).
I plan to deprecate savefig.facecolor/savefig.edgcolor/savefig.transparent anyways (see #9080, #9698); mostly just noting the issue in the meantime.
Activity
QuLogic commentedon Jun 3, 2021
The test code produces a greyscale image in both cases now, probably due to #15239.