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
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.
Bug report
Bug summary
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
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.
Matplotlib version
print(matplotlib.get_backend())
):The text was updated successfully, but these errors were encountered: