Title: Path3DCollection from 3D scatter cannot set_color · Issue #13035 · matplotlib/matplotlib · GitHub
Open Graph Title: Path3DCollection from 3D scatter cannot set_color · Issue #13035 · matplotlib/matplotlib
X Title: Path3DCollection from 3D scatter cannot set_color · Issue #13035 · matplotlib/matplotlib
Description: Bug report Bug summary The set_color method on the Path3DCollection object, such as the one returned by 3D scatter plot, does not set the color. I am filing this as a new issue because all previous instances reported the issue as related...
Open Graph Description: Bug report Bug summary The set_color method on the Path3DCollection object, such as the one returned by 3D scatter plot, does not set the color. I am filing this as a new issue because all previous...
X Description: Bug report Bug summary The set_color method on the Path3DCollection object, such as the one returned by 3D scatter plot, does not set the color. I am filing this as a new issue because all previous...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/13035
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Path3DCollection from 3D scatter cannot set_color","articleBody":"### Bug report\r\n\r\n**Bug summary**\r\nThe `set_color` method on the `Path3DCollection` object, such as the one returned by 3D `scatter` plot, does not set the color. I am filing this as a new issue because\r\n* all [previous instances](3370) reported the issue as related to the [figure not being updated / redrawn](https://stackoverflow.com/a/8974087)\r\n* previous [reports date back more than 3 years](5598) and to version 1.3.1\r\n* the MWE here shows the issue is present even before the first display (`show` call) of the figure\r\n* this report describes some other anomalies related to `alpha` that might favorable to handle together\r\n\r\n**Code for reproduction**\r\n\r\n```python\r\n# Can we change color after plotting? NO, independently of the color format.\r\n# Note: in 2D set_color() works as expected.\r\nimport matplotlib.pyplot as plt\r\nfrom mpl_toolkits.mplot3d import Axes3D\r\nfig = plt.figure()\r\nax = fig.gca(projection = \"3d\")\r\nsc1 = ax.scatter([0,1], [0,1], [1,1], color = (1,0,0,1), depthshade = False)\r\nsc2 = ax.scatter([0,1], [0,1], [2,2], color = (1,0,0,1), alpha=0.3, depthshade = True)\r\nsc3 = ax.scatter([0,1], [0,1], [3,3], color = (1,0,0,1), alpha=1.0, depthshade = False)\r\nsc4 = ax.scatter([0,1], [0,1], [4,4], color = (1,0,0,0.3), alpha=1.0, depthshade = True)\r\nsc1.set_color('blue')\r\nsc2.set_color(['blue', 'blue'])\r\nsc3.set_color([(0,0,1), (0,0,1)])\r\nsc4.set_color([(0,0,1,1), (0,0,1,1)])\r\nsc1.changed() # workaround https://stackoverflow.com/a/8974087 does not work here \r\nax.set_zticks([1,2,3,4])\r\nax.set_zticklabels(['\"blue\"', '[b,b]', 'RGB', 'RGBA'])\r\nfig.show()\r\n```\r\n\r\n**Actual outcome**\r\n\r\n\r\nWhile all the scatter plots are expected to have blue color.\r\n\r\n**Related questions**\r\n\r\nIf the issue is coming from how `Axes3D.scatter` produces the `Path3DCollection`, it might be worthy to note the following on the color-related alpha channel.\r\n\r\nContext: Does depthshade work with alpha value?\r\n* NO, depthshade is negatively overridden if alpha is provided, in addition, channel A from RGBA colors is omitted.\r\n* Remark: Since I did not find any note on this alpha vs channel A interaction in the docs, my expectation was to display using the product of alpha and A. Remark holds for 2D as well.\r\n```python\r\nfig = plt.figure()\r\nax = fig.gca(projection = \"3d\")\r\nsc1 = ax.scatter([0,1], [0,1], [1,1], color = (1,0,0,1), depthshade = False)\r\nsc2 = ax.scatter([0,1], [0,1], [2,2], color = (1,0,0,1), alpha=0.3, depthshade = True)\r\nsc3 = ax.scatter([0,1], [0,1], [3,3], color = (1,0,0,1), alpha=1.0, depthshade = False)\r\nsc4 = ax.scatter([0,1], [0,1], [4,4], color = (1,0,0,0.3), alpha=1.0, depthshade = True)\r\nax.set_zticks([1,2,3,4])\r\nax.set_zticklabels(['A=N a=1', 'A=1 a=.3', 'A=1 a=1', 'A=.3 a=1'])\r\nfig.show()\r\n```\r\n\r\n\r\n\r\nQuestion: Can we change alpha after plotting?\r\n* YES, independently of how alpha was provided.\r\n* Note: `set_alpha()` must be called with single scalar, otherwise a `TypeError` exception is raised.\r\n* Note: it seems that both the scatter constructor and set_alpha writes alpha into the color code because of the following\r\n * `set_alpha(None)` does not restore alpha to 1.0, but reverts the negative override on depthscale\r\n * `set_alpha(1.0)` overrides the A channel of RGBA colors\r\n* Remark: the above behavior is inconsistent with line plotting for the following reasons:\r\n * there, `set_alpha(None)` reverts only the explicitly provided alpha, not the A channel of RGBA colors\r\n * there, `set_alpha(1.0)` does not overwrite the A channel of RGBA colors, but the minimum of the alpha and A is used, however I would prefer product over minimum.\r\n```python\r\nfig = plt.figure()\r\nax = fig.gca(projection = \"3d\")\r\nsc1 = ax.scatter([0,1], [0,1], [1,1], color = (1,0,0,1), alpha=0.3, depthshade = True)\r\nsc2 = ax.scatter([0,1], [0,1], [2,2], color = (1,0,0,1), alpha=0.3, depthshade = True)\r\nsc3 = ax.scatter([0,1], [0,1], [3,3], color = (1,0,0,0.3), depthshade = True)\r\nsc4 = ax.scatter([0,1], [0,1], [4,4], color = (1,0,0,0.3), depthshade = True)\r\nsc1.set_alpha(1.0)\r\nsc2.set_alpha(None)\r\nsc3.set_alpha(None)\r\nsc4.set_alpha(1.0)\r\nax.set_zticks([1,2,3,4])\r\nax.set_zticklabels(['a=.3-\u003e1', 'a=.3-\u003eN', 'A=.3-\u003eN', 'A=.3-\u003e1'])\r\nfig.show()\r\n```\r\n\r\n\r\n\r\n**Matplotlib version**\r\n * Operating system: Windows\r\n * Matplotlib version: 3.0.2\r\n * Matplotlib backend: both module://ipykernel.pylab.backend_inline and Qt5\r\n * Python version: 3.6.7 |Anaconda custom (64-bit)| (default, Dec 10 2018, 20:35:02) [MSC v.1915 64 bit (AMD64)]\r\n\r\n","author":{"url":"https://github.com/stippingerm","@type":"Person","name":"stippingerm"},"datePublished":"2018-12-21T22:23:06.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/13035/matplotlib/issues/13035"}
| 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:bdec0502-cf8a-f9b0-4a38-ff51d0f5f0c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBA6:3F1247:8710A3:B918A7:6A53940C |
| html-safe-nonce | 2c8ac1b5bb8c200add90af0e09d76e96b4d1cc141ef7a6923bf2e0fb3fcd7b90 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkE2OjNGMTI0Nzo4NzEwQTM6QjkxOEE3OjZBNTM5NDBDIiwidmlzaXRvcl9pZCI6Ijc2ODUwMzkyNDI4Mzg1MTI2NTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 332f3cd0c7b75b713a194b6847dcfe5f072a21e0c70131d463b330c480dc41d1 |
| hovercard-subject-tag | issue:393606605 |
| 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/13035/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30f5cd1e26aa23f1a282753acc2dcce97489f24c6554d796a1f8136c7ad8bcf7/matplotlib/matplotlib/issues/13035 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30f5cd1e26aa23f1a282753acc2dcce97489f24c6554d796a1f8136c7ad8bcf7/matplotlib/matplotlib/issues/13035 |
| og:image:alt | Bug report Bug summary The set_color method on the Path3DCollection object, such as the one returned by 3D scatter plot, does not set the color. I am filing this as a new issue because all previous... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | stippingerm |
| 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