{"action":"created","comment":{"url":"https://api.github.com/repos/has2k1/plotnine/pulls/comments/244475419","pull_request_review_id":188403844,"id":244475419,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0NDQ3NTQxOQ==","diff_hunk":"@@ -0,0 +1,127 @@\n+from matplotlib.collections import PolyCollection\n+import pandas as pd\n+import numpy as np\n+\n+from ..utils import to_rgba, SIZE_FACTOR\n+from ..doctools import document\n+from ..layer import layer\n+from ..coords import coord_flip\n+from ..scales.scale import scale_discrete\n+from .geom import geom\n+from .annotate import annotate\n+\n+\n+@document\n+class annotation_alternating_background(annotate):\n+    \"\"\"\n+    Alternating backgrounds, centered around each label on x-axis.\n+    (Use coord_flip for y-axis)\n+\n+    Useful for geom_jitter.\n+\n+    {usage}\n+    plot += annotation_alternating_background(fill=['red', 'blue'], alpha=0.3)\n+\n+    Parameters\n+    ----------\n+    fills - list of colors to alternate through.\n+    Default: [\"#AAAAAA\", \"#CCCCCC\"]\n+\n+    {common_parameters}\n+    \"\"\"\n+\n+    def __init__(self, **kwargs):\n+        self._annotation_geom = _geom_annotation_alternating_background(\n+            **kwargs)\n+\n+    def __radd__(self, gg, inplace=False):","path":"plotnine/geoms/annotation_alternating_background.py","position":37,"original_position":37,"commit_id":"b567e0f52f6d51881a27f26b809cd3bced6775d5","original_commit_id":"b567e0f52f6d51881a27f26b809cd3bced6775d5","user":{"login":"has2k1","id":780341,"node_id":"MDQ6VXNlcjc4MDM0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/780341?v=4","gravatar_id":"","url":"https://api.github.com/users/has2k1","html_url":"https://github.com/has2k1","followers_url":"https://api.github.com/users/has2k1/followers","following_url":"https://api.github.com/users/has2k1/following{/other_user}","gists_url":"https://api.github.com/users/has2k1/gists{/gist_id}","starred_url":"https://api.github.com/users/has2k1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/has2k1/subscriptions","organizations_url":"https://api.github.com/users/has2k1/orgs","repos_url":"https://api.github.com/users/has2k1/repos","events_url":"https://api.github.com/users/has2k1/events{/privacy}","received_events_url":"https://api.github.com/users/has2k1/received_events","type":"User","site_admin":false},"body":"There is no need for this __radd__.\r\n\r\nBeing extra helpful to the user by forcing the this annotation to be the lowest layer has two consequences.\r\n\r\n1. It limits how creative the user can be with the layer.\r\n2. The code in other places has to be broken-up and rearranged to suit this functionality.\r\n\r\nThe burden should be on the user to put the layer created by this annotation in the right position. Users of this library learn quickly that they have to manage the order of the layers.\r\n","created_at":"2018-12-29T10:11:30Z","updated_at":"2018-12-29T10:32:28Z","html_url":"https://github.com/has2k1/plotnine/pull/230#discussion_r244475419","pull_request_url":"https://api.github.com/repos/has2k1/plotnine/pulls/230","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/comments/244475419"},"html":{"href":"https://github.com/has2k1/plotnine/pull/230#discussion_r244475419"},"pull_request":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/230"}}},"pull_request":{"url":"https://api.github.com/repos/has2k1/plotnine/pulls/230","id":230433984,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMwNDMzOTg0","html_url":"https://github.com/has2k1/plotnine/pull/230","diff_url":"https://github.com/has2k1/plotnine/pull/230.diff","patch_url":"https://github.com/has2k1/plotnine/pull/230.patch","issue_url":"https://api.github.com/repos/has2k1/plotnine/issues/230","number":230,"state":"open","locked":false,"title":"introduced annotation_alternating_backgrounds","user":{"login":"TyberiusPrime","id":1257580,"node_id":"MDQ6VXNlcjEyNTc1ODA=","avatar_url":"https://avatars2.githubusercontent.com/u/1257580?v=4","gravatar_id":"","url":"https://api.github.com/users/TyberiusPrime","html_url":"https://github.com/TyberiusPrime","followers_url":"https://api.github.com/users/TyberiusPrime/followers","following_url":"https://api.github.com/users/TyberiusPrime/following{/other_user}","gists_url":"https://api.github.com/users/TyberiusPrime/gists{/gist_id}","starred_url":"https://api.github.com/users/TyberiusPrime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TyberiusPrime/subscriptions","organizations_url":"https://api.github.com/users/TyberiusPrime/orgs","repos_url":"https://api.github.com/users/TyberiusPrime/repos","events_url":"https://api.github.com/users/TyberiusPrime/events{/privacy}","received_events_url":"https://api.github.com/users/TyberiusPrime/received_events","type":"User","site_admin":false},"body":"This PR introduces an annotation that adds 'alternating'  backgrounds,\r\nwhich is useful to increase readability in tight jitter plots on categorical x-axis data.\r\nExample:\r\n```python\r\nimport plotnine as p9\r\nfrom plotnine.data import mtcars\r\ng = p9.ggplot(mtcars.assign(\r\n    gear = pd.Categorical(mtcars.gear),\r\n    am = pd.Categorical(mtcars.am)\r\n))\r\ng += p9.geom_jitter(p9.aes(\"gear\", 'wt', color='am'), width=.45, height=0)\r\ng += p9.annotation_alternating_background(fills=['grey','darkgrey'],                                         \r\n                                          alpha=.5)\r\ng += p9.scale_color_manual(['red','blue'])\r\n```\r\n![image](https://user-images.githubusercontent.com/1257580/48409204-78c40880-e73b-11e8-9325-64695f6aa62e.png)\r\n\r\n\r\nSupports coord_flip:\r\n![image](https://user-images.githubusercontent.com/1257580/48409232-8b3e4200-e73b-11e8-9bfa-5dde2fcb3afd.png)\r\n\r\nAnd more than 2 colors, and does something sensible with non-discrete axis \r\n(ie. change shade halfway between labels)\r\n![image](https://user-images.githubusercontent.com/1257580/48409575-79a96a00-e73c-11e8-9959-4f4b89514a1b.png)\r\n\r\n\r\n\r\n\r\n","created_at":"2018-11-13T11:06:28Z","updated_at":"2018-12-29T10:32:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5216475595943a079f9a841d0b162c00f24c2daf","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/has2k1/plotnine/pulls/230/commits","review_comments_url":"https://api.github.com/repos/has2k1/plotnine/pulls/230/comments","review_comment_url":"https://api.github.com/repos/has2k1/plotnine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/has2k1/plotnine/issues/230/comments","statuses_url":"https://api.github.com/repos/has2k1/plotnine/statuses/b567e0f52f6d51881a27f26b809cd3bced6775d5","head":{"label":"TyberiusPrime:alternate_backgrounds","ref":"alternate_backgrounds","sha":"b567e0f52f6d51881a27f26b809cd3bced6775d5","user":{"login":"TyberiusPrime","id":1257580,"node_id":"MDQ6VXNlcjEyNTc1ODA=","avatar_url":"https://avatars2.githubusercontent.com/u/1257580?v=4","gravatar_id":"","url":"https://api.github.com/users/TyberiusPrime","html_url":"https://github.com/TyberiusPrime","followers_url":"https://api.github.com/users/TyberiusPrime/followers","following_url":"https://api.github.com/users/TyberiusPrime/following{/other_user}","gists_url":"https://api.github.com/users/TyberiusPrime/gists{/gist_id}","starred_url":"https://api.github.com/users/TyberiusPrime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TyberiusPrime/subscriptions","organizations_url":"https://api.github.com/users/TyberiusPrime/orgs","repos_url":"https://api.github.com/users/TyberiusPrime/repos","events_url":"https://api.github.com/users/TyberiusPrime/events{/privacy}","received_events_url":"https://api.github.com/users/TyberiusPrime/received_events","type":"User","site_admin":false},"repo":{"id":150585509,"node_id":"MDEwOlJlcG9zaXRvcnkxNTA1ODU1MDk=","name":"plotnine","full_name":"TyberiusPrime/plotnine","private":false,"owner":{"login":"TyberiusPrime","id":1257580,"node_id":"MDQ6VXNlcjEyNTc1ODA=","avatar_url":"https://avatars2.githubusercontent.com/u/1257580?v=4","gravatar_id":"","url":"https://api.github.com/users/TyberiusPrime","html_url":"https://github.com/TyberiusPrime","followers_url":"https://api.github.com/users/TyberiusPrime/followers","following_url":"https://api.github.com/users/TyberiusPrime/following{/other_user}","gists_url":"https://api.github.com/users/TyberiusPrime/gists{/gist_id}","starred_url":"https://api.github.com/users/TyberiusPrime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TyberiusPrime/subscriptions","organizations_url":"https://api.github.com/users/TyberiusPrime/orgs","repos_url":"https://api.github.com/users/TyberiusPrime/repos","events_url":"https://api.github.com/users/TyberiusPrime/events{/privacy}","received_events_url":"https://api.github.com/users/TyberiusPrime/received_events","type":"User","site_admin":false},"html_url":"https://github.com/TyberiusPrime/plotnine","description":"A grammar of graphics for Python","fork":true,"url":"https://api.github.com/repos/TyberiusPrime/plotnine","forks_url":"https://api.github.com/repos/TyberiusPrime/plotnine/forks","keys_url":"https://api.github.com/repos/TyberiusPrime/plotnine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TyberiusPrime/plotnine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TyberiusPrime/plotnine/teams","hooks_url":"https://api.github.com/repos/TyberiusPrime/plotnine/hooks","issue_events_url":"https://api.github.com/repos/TyberiusPrime/plotnine/issues/events{/number}","events_url":"https://api.github.com/repos/TyberiusPrime/plotnine/events","assignees_url":"https://api.github.com/repos/TyberiusPrime/plotnine/assignees{/user}","branches_url":"https://api.github.com/repos/TyberiusPrime/plotnine/branches{/branch}","tags_url":"https://api.github.com/repos/TyberiusPrime/plotnine/tags","blobs_url":"https://api.github.com/repos/TyberiusPrime/plotnine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TyberiusPrime/plotnine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TyberiusPrime/plotnine/git/refs{/sha}","trees_url":"https://api.github.com/repos/TyberiusPrime/plotnine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TyberiusPrime/plotnine/statuses/{sha}","languages_url":"https://api.github.com/repos/TyberiusPrime/plotnine/languages","stargazers_url":"https://api.github.com/repos/TyberiusPrime/plotnine/stargazers","contributors_url":"https://api.github.com/repos/TyberiusPrime/plotnine/contributors","subscribers_url":"https://api.github.com/repos/TyberiusPrime/plotnine/subscribers","subscription_url":"https://api.github.com/repos/TyberiusPrime/plotnine/subscription","commits_url":"https://api.github.com/repos/TyberiusPrime/plotnine/commits{/sha}","git_commits_url":"https://api.github.com/repos/TyberiusPrime/plotnine/git/commits{/sha}","comments_url":"https://api.github.com/repos/TyberiusPrime/plotnine/comments{/number}","issue_comment_url":"https://api.github.com/repos/TyberiusPrime/plotnine/issues/comments{/number}","contents_url":"https://api.github.com/repos/TyberiusPrime/plotnine/contents/{+path}","compare_url":"https://api.github.com/repos/TyberiusPrime/plotnine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TyberiusPrime/plotnine/merges","archive_url":"https://api.github.com/repos/TyberiusPrime/plotnine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TyberiusPrime/plotnine/downloads","issues_url":"https://api.github.com/repos/TyberiusPrime/plotnine/issues{/number}","pulls_url":"https://api.github.com/repos/TyberiusPrime/plotnine/pulls{/number}","milestones_url":"https://api.github.com/repos/TyberiusPrime/plotnine/milestones{/number}","notifications_url":"https://api.github.com/repos/TyberiusPrime/plotnine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TyberiusPrime/plotnine/labels{/name}","releases_url":"https://api.github.com/repos/TyberiusPrime/plotnine/releases{/id}","deployments_url":"https://api.github.com/repos/TyberiusPrime/plotnine/deployments","created_at":"2018-09-27T12:45:34Z","updated_at":"2018-11-21T15:32:06Z","pushed_at":"2018-12-19T13:19:30Z","git_url":"git://github.com/TyberiusPrime/plotnine.git","ssh_url":"git@github.com:TyberiusPrime/plotnine.git","clone_url":"https://github.com/TyberiusPrime/plotnine.git","svn_url":"https://github.com/TyberiusPrime/plotnine","homepage":"https://plotnine.readthedocs.io/en/stable/","size":7083,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"has2k1:master","ref":"master","sha":"4ca88fbf713ec883010c2f021649f10c3625e528","user":{"login":"has2k1","id":780341,"node_id":"MDQ6VXNlcjc4MDM0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/780341?v=4","gravatar_id":"","url":"https://api.github.com/users/has2k1","html_url":"https://github.com/has2k1","followers_url":"https://api.github.com/users/has2k1/followers","following_url":"https://api.github.com/users/has2k1/following{/other_user}","gists_url":"https://api.github.com/users/has2k1/gists{/gist_id}","starred_url":"https://api.github.com/users/has2k1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/has2k1/subscriptions","organizations_url":"https://api.github.com/users/has2k1/orgs","repos_url":"https://api.github.com/users/has2k1/repos","events_url":"https://api.github.com/users/has2k1/events{/privacy}","received_events_url":"https://api.github.com/users/has2k1/received_events","type":"User","site_admin":false},"repo":{"id":89276692,"node_id":"MDEwOlJlcG9zaXRvcnk4OTI3NjY5Mg==","name":"plotnine","full_name":"has2k1/plotnine","private":false,"owner":{"login":"has2k1","id":780341,"node_id":"MDQ6VXNlcjc4MDM0MQ==","avatar_url":"https://avatars1.githubusercontent.com/u/780341?v=4","gravatar_id":"","url":"https://api.github.com/users/has2k1","html_url":"https://github.com/has2k1","followers_url":"https://api.github.com/users/has2k1/followers","following_url":"https://api.github.com/users/has2k1/following{/other_user}","gists_url":"https://api.github.com/users/has2k1/gists{/gist_id}","starred_url":"https://api.github.com/users/has2k1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/has2k1/subscriptions","organizations_url":"https://api.github.com/users/has2k1/orgs","repos_url":"https://api.github.com/users/has2k1/repos","events_url":"https://api.github.com/users/has2k1/events{/privacy}","received_events_url":"https://api.github.com/users/has2k1/received_events","type":"User","site_admin":false},"html_url":"https://github.com/has2k1/plotnine","description":"A grammar of graphics for Python","fork":false,"url":"https://api.github.com/repos/has2k1/plotnine","forks_url":"https://api.github.com/repos/has2k1/plotnine/forks","keys_url":"https://api.github.com/repos/has2k1/plotnine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/has2k1/plotnine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/has2k1/plotnine/teams","hooks_url":"https://api.github.com/repos/has2k1/plotnine/hooks","issue_events_url":"https://api.github.com/repos/has2k1/plotnine/issues/events{/number}","events_url":"https://api.github.com/repos/has2k1/plotnine/events","assignees_url":"https://api.github.com/repos/has2k1/plotnine/assignees{/user}","branches_url":"https://api.github.com/repos/has2k1/plotnine/branches{/branch}","tags_url":"https://api.github.com/repos/has2k1/plotnine/tags","blobs_url":"https://api.github.com/repos/has2k1/plotnine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/has2k1/plotnine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/has2k1/plotnine/git/refs{/sha}","trees_url":"https://api.github.com/repos/has2k1/plotnine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/has2k1/plotnine/statuses/{sha}","languages_url":"https://api.github.com/repos/has2k1/plotnine/languages","stargazers_url":"https://api.github.com/repos/has2k1/plotnine/stargazers","contributors_url":"https://api.github.com/repos/has2k1/plotnine/contributors","subscribers_url":"https://api.github.com/repos/has2k1/plotnine/subscribers","subscription_url":"https://api.github.com/repos/has2k1/plotnine/subscription","commits_url":"https://api.github.com/repos/has2k1/plotnine/commits{/sha}","git_commits_url":"https://api.github.com/repos/has2k1/plotnine/git/commits{/sha}","comments_url":"https://api.github.com/repos/has2k1/plotnine/comments{/number}","issue_comment_url":"https://api.github.com/repos/has2k1/plotnine/issues/comments{/number}","contents_url":"https://api.github.com/repos/has2k1/plotnine/contents/{+path}","compare_url":"https://api.github.com/repos/has2k1/plotnine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/has2k1/plotnine/merges","archive_url":"https://api.github.com/repos/has2k1/plotnine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/has2k1/plotnine/downloads","issues_url":"https://api.github.com/repos/has2k1/plotnine/issues{/number}","pulls_url":"https://api.github.com/repos/has2k1/plotnine/pulls{/number}","milestones_url":"https://api.github.com/repos/has2k1/plotnine/milestones{/number}","notifications_url":"https://api.github.com/repos/has2k1/plotnine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/has2k1/plotnine/labels{/name}","releases_url":"https://api.github.com/repos/has2k1/plotnine/releases{/id}","deployments_url":"https://api.github.com/repos/has2k1/plotnine/deployments","created_at":"2017-04-24T19:00:44Z","updated_at":"2018-12-29T09:54:15Z","pushed_at":"2018-12-29T09:54:13Z","git_url":"git://github.com/has2k1/plotnine.git","ssh_url":"git@github.com:has2k1/plotnine.git","clone_url":"https://github.com/has2k1/plotnine.git","svn_url":"https://github.com/has2k1/plotnine","homepage":"https://plotnine.readthedocs.io/en/stable/","size":7048,"stargazers_count":1426,"watchers_count":1426,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":72,"mirror_url":null,"archived":false,"open_issues_count":31,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":72,"open_issues":31,"watchers":1426,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/230"},"html":{"href":"https://github.com/has2k1/plotnine/pull/230"},"issue":{"href":"https://api.github.com/repos/has2k1/plotnine/issues/230"},"comments":{"href":"https://api.github.com/repos/has2k1/plotnine/issues/230/comments"},"review_comments":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/230/comments"},"review_comment":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/has2k1/plotnine/pulls/230/commits"},"statuses":{"href":"https://api.github.com/repos/has2k1/plotnine/statuses/b567e0f52f6d51881a27f26b809cd3bced6775d5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"has2k1"}}