{"action":"created","issue":{"url":"https://api.github.com/repos/nilearn/nilearn/issues/1758","repository_url":"https://api.github.com/repos/nilearn/nilearn","labels_url":"https://api.github.com/repos/nilearn/nilearn/issues/1758/labels{/name}","comments_url":"https://api.github.com/repos/nilearn/nilearn/issues/1758/comments","events_url":"https://api.github.com/repos/nilearn/nilearn/issues/1758/events","html_url":"https://github.com/nilearn/nilearn/pull/1758","id":359904191,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1Mjg5MDQz","number":1758,"title":"BUG: Fix alpha for transparent colormaps","user":{"login":"larsoner","id":2365790,"node_id":"MDQ6VXNlcjIzNjU3OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/2365790?v=4","gravatar_id":"","url":"https://api.github.com/users/larsoner","html_url":"https://github.com/larsoner","followers_url":"https://api.github.com/users/larsoner/followers","following_url":"https://api.github.com/users/larsoner/following{/other_user}","gists_url":"https://api.github.com/users/larsoner/gists{/gist_id}","starred_url":"https://api.github.com/users/larsoner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsoner/subscriptions","organizations_url":"https://api.github.com/users/larsoner/orgs","repos_url":"https://api.github.com/users/larsoner/repos","events_url":"https://api.github.com/users/larsoner/events{/privacy}","received_events_url":"https://api.github.com/users/larsoner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-13T13:48:27Z","updated_at":"2018-09-13T21:00:49Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/nilearn/nilearn/pulls/1758","html_url":"https://github.com/nilearn/nilearn/pull/1758","diff_url":"https://github.com/nilearn/nilearn/pull/1758.diff","patch_url":"https://github.com/nilearn/nilearn/pull/1758.patch"},"body":"For plotting functions, the colorbar has a white background. This is problematic because colormaps with an alpha channel are displayed incorrectly. This sets the background color to mid gray, and thus also sets the `cmaplist` entries that are below `threshold` just to be fully transparent. This should have the same effect as using `(0.5, 0.5, 0.5, 1.0)` directly but is more consistent with what the plotting is actually doing."},"comment":{"url":"https://api.github.com/repos/nilearn/nilearn/issues/comments/421151675","html_url":"https://github.com/nilearn/nilearn/pull/1758#issuecomment-421151675","issue_url":"https://api.github.com/repos/nilearn/nilearn/issues/1758","id":421151675,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTE1MTY3NQ==","user":{"login":"larsoner","id":2365790,"node_id":"MDQ6VXNlcjIzNjU3OTA=","avatar_url":"https://avatars1.githubusercontent.com/u/2365790?v=4","gravatar_id":"","url":"https://api.github.com/users/larsoner","html_url":"https://github.com/larsoner","followers_url":"https://api.github.com/users/larsoner/followers","following_url":"https://api.github.com/users/larsoner/following{/other_user}","gists_url":"https://api.github.com/users/larsoner/gists{/gist_id}","starred_url":"https://api.github.com/users/larsoner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/larsoner/subscriptions","organizations_url":"https://api.github.com/users/larsoner/orgs","repos_url":"https://api.github.com/users/larsoner/repos","events_url":"https://api.github.com/users/larsoner/events{/privacy}","received_events_url":"https://api.github.com/users/larsoner/received_events","type":"User","site_admin":false},"created_at":"2018-09-13T21:00:49Z","updated_at":"2018-09-13T21:00:49Z","author_association":"CONTRIBUTOR","body":"It requires using a colormap with custom alpha in your colormap, like:\r\n```\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib.colors import ListedColormap\r\nfrom nilearn import plotting\r\nfrom nilearn import datasets\r\n\r\ncmap = plt.get_cmap('viridis')(np.linspace(0, 1, 256))\r\ncmap[:, 3] = np.clip(np.abs(np.linspace(-1, 1, 256)), 0, 1)  # middle should have opacity=0\r\ncmap = ListedColormap(cmap)\r\n\r\nmotor_images = datasets.fetch_neurovault_motor_task()\r\nstat_img = motor_images.images[0]\r\ndisplay = plotting.plot_stat_map(stat_img, threshold=None, colorbar=True,\r\n                                 cmap=cmap)\r\n```\r\nOn `master` the middle becomes white even though it's transparent (wrong):\r\n![screenshot from 2018-09-13 16-59-13](https://user-images.githubusercontent.com/2365790/45515526-67c83c80-b776-11e8-93b3-7e73a5b4de78.png)\r\n\r\nOn this PR it goes to middle gray (right / consistent with what `threshold` does):\r\n![screenshot from 2018-09-13 17-00-14](https://user-images.githubusercontent.com/2365790/45515562-82021a80-b776-11e8-8cf9-81759d9d2faf.png)\r\n"}}
{"actor":{"display_login":"larsoner"}}