Title: Patches eagerly resolve colors and apply alpha, but should do so lazily like Line2Ds · Issue #11710 · matplotlib/matplotlib · GitHub
Open Graph Title: Patches eagerly resolve colors and apply alpha, but should do so lazily like Line2Ds · Issue #11710 · matplotlib/matplotlib
X Title: Patches eagerly resolve colors and apply alpha, but should do so lazily like Line2Ds · Issue #11710 · matplotlib/matplotlib
Description: Consider the following example: from matplotlib.pyplot import Line2D, Rectangle l = Line2D([], [], alpha=.5) l.set_color("red") print(l.get_color()) r = Rectangle((0, 0), 1, 1, alpha=.5) r.set_facecolor("red") print(r.get_facecolor()) Th...
Open Graph Description: Consider the following example: from matplotlib.pyplot import Line2D, Rectangle l = Line2D([], [], alpha=.5) l.set_color("red") print(l.get_color()) r = Rectangle((0, 0), 1, 1, alpha=.5) r.set_face...
X Description: Consider the following example: from matplotlib.pyplot import Line2D, Rectangle l = Line2D([], [], alpha=.5) l.set_color("red") print(l.get_color()) r = Rectangle((0, 0), 1, 1, alpha=.5) ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/11710
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Patches eagerly resolve colors and apply alpha, but should do so lazily like Line2Ds","articleBody":"Consider the following example:\r\n```\r\nfrom matplotlib.pyplot import Line2D, Rectangle\r\n\r\nl = Line2D([], [], alpha=.5)\r\nl.set_color(\"red\")\r\nprint(l.get_color())\r\n\r\nr = Rectangle((0, 0), 1, 1, alpha=.5)\r\nr.set_facecolor(\"red\")\r\nprint(r.get_facecolor())\r\n```\r\n\r\nThe line reports its color as \"red\", but the rectangle reports it as (1, 0, 0, .5). This is because patches immediately resolve colors and apply alphas; to do so they need to maintain an elaborate dance involving _original_facecolor and _original_edgecolor. Conversely, Line2D doesn't resolve colors eagerly (they just store whatever was passed in), and perform the conversion in draw().\r\n\r\nAs an other example, consider\r\n```\r\nfrom pylab import *\r\nfrom matplotlib.pyplot import Line2D, Rectangle\r\n\r\nax = gca()\r\nax.add_artist(Line2D([0, 1], [.5, 1], color=\"C0\"))\r\nax.add_artist(Rectangle((0, 0), 1, .5, color=\"C0\"))\r\nrcParams[\"axes.prop_cycle\"] = cycler(color=[\"r\", \"g\", \"b\"])\r\n\r\nshow()\r\n```\r\nThis will draw a red line (draw-time resolution is affected by the new prop_cycle), but a blue rectangle (eager resolution uses the original prop_cycle).\r\n\r\nI think the behavior of Line2D makes more sense (at least the output of get_facecolor() immediately after a set_facecolor() should be what we set...), this would also avoid issues such as #11702/#11703.\r\n\r\n(mpl master and probably since a long time ago)","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2018-07-20T07:32:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/11710/matplotlib/issues/11710"}
| 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:cf2dc216-3b0e-0eed-2611-9d0210dee684 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C40C:14BBA:CFD684:11E5BD4:6A53A87B |
| html-safe-nonce | ea5c1168472a603a005d4f40000ba56d516ef110749c0281f16353ae9f096f6c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNDBDOjE0QkJBOkNGRDY4NDoxMUU1QkQ0OjZBNTNBODdCIiwidmlzaXRvcl9pZCI6IjQ1MzM2MjI4MTIwNTgwMzYzNDciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cda26847a6a9c3ffe86f586018f96a49b3df604c1601a2da80cdaafb96b12578 |
| hovercard-subject-tag | issue:343002743 |
| 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/11710/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de568ef358dcdd3e2997335cc0b20d75b6eb126b27221b21de76fb4442f930c9/matplotlib/matplotlib/issues/11710 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de568ef358dcdd3e2997335cc0b20d75b6eb126b27221b21de76fb4442f930c9/matplotlib/matplotlib/issues/11710 |
| og:image:alt | Consider the following example: from matplotlib.pyplot import Line2D, Rectangle l = Line2D([], [], alpha=.5) l.set_color("red") print(l.get_color()) r = Rectangle((0, 0), 1, 1, alpha=.5) r.set_face... |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width