Title: Transparency in Animations · Issue #5335 · matplotlib/matplotlib · GitHub
Open Graph Title: Transparency in Animations · Issue #5335 · matplotlib/matplotlib
X Title: Transparency in Animations · Issue #5335 · matplotlib/matplotlib
Description: This report is somewhat of an extension to #5302. It seems easy to miss handle transparent regions while working with nbagg. The following is an example taken from the animation examples: %matplotlib nbagg import matplotlib.pyplot as plt...
Open Graph Description: This report is somewhat of an extension to #5302. It seems easy to miss handle transparent regions while working with nbagg. The following is an example taken from the animation examples: %matplotl...
X Description: This report is somewhat of an extension to #5302. It seems easy to miss handle transparent regions while working with nbagg. The following is an example taken from the animation examples: %matplotl...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/5335
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Transparency in Animations","articleBody":"This report is somewhat of an extension to #5302. It seems easy to miss handle transparent regions while working with nbagg. The following is an example taken from the animation examples:\n\n```\n%matplotlib nbagg\n\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\nimport numpy as np\n\ndef update_line(num, data, line):\n line.set_data(data[...,:num])\n return line,\n\nfig = plt.figure()\n\nplt.xlim(0, 1)\nplt.ylim(0, 1)\nplt.xlabel('x')\nplt.title('test')\n\ndata = np.random.rand(2, 25)\nl, = plt.plot([], [], 'r-')\n\nani = animation.FuncAnimation(fig, update_line, 25, fargs=(data, l),\n interval=50, blit=True)\n\nani.save('im.gif', writer='imagemagick', fps=8)\nani.save('im.mp4', extra_args=['-vcodec', 'libx264'])\n```\n\nThe output produced is:\n\n\n\nAs you can see, there is again some issues with the rendering of text in the figure (not axes) area where nbagg has set transparency to true. The im.mp4 file looks nearly identical to the gif. \n\nI believe matplotlib saves each frame as a png and then sends those pngs to be saved as an animation through convert (imagemagick) or ffmpeg. I believe the issue here is that while gifs properly support transparency, they only support either full alpha or no alpha, which forces imagemagick to decide between alpha or no alpha for each intermediate alpha which gives a pixelated appearance.\n\nIf we insert the code [for some reason `with plt.rc_context({'nbagg.transparent': False})` doesn't work here]:\n\n```\nimport matplotlib\nmatplotlib.rcParams['nbagg.transparent'] = False\n```\n\nThen we will get this:\n\n\n\nPerhaps we can just disable transparency for gif files all together (I don't think matplotlib can properly handle boolean alpha levels), and then set the default frame format to gif files for animations; `animation.frame_format: 'gif'`\n","author":{"url":"https://github.com/cbreeden","@type":"Person","name":"cbreeden"},"datePublished":"2015-10-27T23:55:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/5335/matplotlib/issues/5335"}
| 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:bb77a96c-1d28-2dd6-7913-ee079cd191b7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EC3C:3625E7:5CC1E7:7E0903:6A53472F |
| html-safe-nonce | 06ac970411d4246e61c1da9b54f263cbc2f08472fc9176532e4c68b966a0590f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQzNDOjM2MjVFNzo1Q0MxRTc6N0UwOTAzOjZBNTM0NzJGIiwidmlzaXRvcl9pZCI6IjUzNjk5NzAyMTQzNzYyNjE0MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 69248980485be7aa9da7235a76d53dc9ef8c9b0656ed07ef6d0ca87c3229c3fe |
| hovercard-subject-tag | issue:113714022 |
| 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/5335/issue_layout |
| twitter:image | https://opengraph.githubassets.com/63db84bb60718f2af3fc1625d0e733d4a479ea6230c9db83e585afe9f39f4d40/matplotlib/matplotlib/issues/5335 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/63db84bb60718f2af3fc1625d0e733d4a479ea6230c9db83e585afe9f39f4d40/matplotlib/matplotlib/issues/5335 |
| og:image:alt | This report is somewhat of an extension to #5302. It seems easy to miss handle transparent regions while working with nbagg. The following is an example taken from the animation examples: %matplotl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cbreeden |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width