Title: Inconsistent behavior for savefig.facecolor + savefig.transparent depending on output format · Issue #9921 · matplotlib/matplotlib · GitHub
Open Graph Title: Inconsistent behavior for savefig.facecolor + savefig.transparent depending on output format · Issue #9921 · matplotlib/matplotlib
X Title: Inconsistent behavior for savefig.facecolor + savefig.transparent depending on output format · Issue #9921 · matplotlib/matplotlib
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 * ...
Open Graph 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_im...
X 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_im...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/9921
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistent behavior for savefig.facecolor + savefig.transparent depending on output format","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nSetting both savefig.facecolor and savefig.transparent behaves differently depending on whether the image is saved as jpeg or png.\r\n\r\n**Code for reproduction**\r\n\r\nmodified from test_image.test_jpeg_alpha\r\n\r\n```python\r\nfrom pylab import *\r\nrcdefaults()\r\n\r\nplt.figure(figsize=(1, 1), dpi=300)\r\n# Create an image that is all black, with a gradient from 0-1 in\r\n# the alpha channel from left to right.\r\nim = np.zeros((300, 300, 4), dtype=float)\r\nim[..., 3] = np.linspace(0.0, 1.0, 300)\r\n\r\nplt.figimage(im)\r\n\r\nwith rc_context({'savefig.facecolor': 'red', 'savefig.transparent': True}):\r\n plt.savefig(\"/tmp/test.jpg\")\r\n plt.savefig(\"/tmp/test.png\")\r\n```\r\n\r\n**Actual outcome**\r\n\r\ntest.png\r\n\r\n\r\ntest.jpg\r\n\r\n\r\n\r\n**Expected outcome**\r\n\r\nSome 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).\r\n\r\nI plan to deprecate savefig.facecolor/savefig.edgcolor/savefig.transparent anyways (see #9080, #9698); mostly just noting the issue in the meantime.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system:\r\n * Matplotlib version: master and 2.1\r\n * Matplotlib backend (`print(matplotlib.get_backend())`):\r\n * Python version:\r\n * Jupyter version (if applicable):\r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2017-12-04T03:21:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/9921/matplotlib/issues/9921"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f9df44bf-09e5-58d7-6aca-ce10864eade3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9A46:1525EF:1788AD0:1EF01AB:6A51C6EB |
| html-safe-nonce | 9b0ed8b80f751040cf01f576cc74d8d127072d607344d125ce5b363983a658de |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QTQ2OjE1MjVFRjoxNzg4QUQwOjFFRjAxQUI6NkE1MUM2RUIiLCJ2aXNpdG9yX2lkIjoiNzY1OTc4NjI5MTEzMTgyNzk0NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2a56c51d418d5a8951f5e0a25fd5af9e9b94223410c05436b82cc220fd3bbd2e |
| hovercard-subject-tag | issue:278858797 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/9921/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f75af7b6f2ffc16eb97a1a2f5927ce8b8a45cbb84c02fb6fc077536134a8a7cb/matplotlib/matplotlib/issues/9921 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f75af7b6f2ffc16eb97a1a2f5927ce8b8a45cbb84c02fb6fc077536134a8a7cb/matplotlib/matplotlib/issues/9921 |
| og:image:alt | 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_im... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width