Closed
Description
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
from pylab import *
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)
with rc_context({'savefig.facecolor': 'red', 'savefig.transparent': True}):
plt.savefig("/tmp/test.jpg")
plt.savefig("/tmp/test.png")
Actual outcome
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
- Operating system:
- Matplotlib version: master and 2.1
- Matplotlib backend (
print(matplotlib.get_backend())
): - Python version:
- Jupyter version (if applicable):
- Other libraries:
Metadata
Metadata
Assignees
Labels
No labels