{"action":"created","comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/92866598","pull_request_review_id":13390842,"id":92866598,"diff_hunk":"@@ -0,0 +1,85 @@\n+\"\"\"\n+=====================================================================\n+Examples of normalization using  :class:`~matplotlib.colors.FuncNorm`\n+=====================================================================\n+\n+This is an example on how to perform a normalization using an arbitrary\n+function with :class:`~matplotlib.colors.FuncNorm`. A logarithm normalization\n+and a square root normalization will be use as examples.\n+\n+\"\"\"\n+\n+import matplotlib.cm as cm\n+import matplotlib.colors as colors\n+import matplotlib.pyplot as plt\n+\n+import numpy as np\n+\n+\n+def main():\n+    fig, axes = plt.subplots(3, 2, gridspec_kw={\n+              'width_ratios': [1, 3.5]}, figsize=plt.figaspect(0.6))\n+\n+    # Example of logarithm normalization using FuncNorm\n+    norm_log = colors.FuncNorm(f='log10', vmin=0.01)\n+    # The same can be achieved with","path":"examples/color/colormap_normalizations_funcnorm.py","position":25,"original_position":25,"commit_id":"0ffcb7253df571107bf7e1c933849f3d6e9eb46c","original_commit_id":"0ffcb7253df571107bf7e1c933849f3d6e9eb46c","user":{"login":"story645","id":1300499,"avatar_url":"https://avatars.githubusercontent.com/u/1300499?v=3","gravatar_id":"","url":"https://api.github.com/users/story645","html_url":"https://github.com/story645","followers_url":"https://api.github.com/users/story645/followers","following_url":"https://api.github.com/users/story645/following{/other_user}","gists_url":"https://api.github.com/users/story645/gists{/gist_id}","starred_url":"https://api.github.com/users/story645/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/story645/subscriptions","organizations_url":"https://api.github.com/users/story645/orgs","repos_url":"https://api.github.com/users/story645/repos","events_url":"https://api.github.com/users/story645/events{/privacy}","received_events_url":"https://api.github.com/users/story645/received_events","type":"User","site_admin":false},"body":"this comment should be dropped and there should be a standalone example for that feature","created_at":"2016-12-16T19:01:34Z","updated_at":"2016-12-16T19:01:34Z","html_url":"https://github.com/matplotlib/matplotlib/pull/7631#discussion_r92866598","pull_request_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631","_links":{"self":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments/92866598"},"html":{"href":"https://github.com/matplotlib/matplotlib/pull/7631#discussion_r92866598"},"pull_request":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631"}}},"pull_request":{"url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631","id":98259027,"html_url":"https://github.com/matplotlib/matplotlib/pull/7631","diff_url":"https://github.com/matplotlib/matplotlib/pull/7631.diff","patch_url":"https://github.com/matplotlib/matplotlib/pull/7631.patch","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/7631","number":7631,"state":"open","locked":false,"title":"ENH: Added FuncNorm","user":{"login":"alvarosg","id":12649253,"avatar_url":"https://avatars.githubusercontent.com/u/12649253?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosg","html_url":"https://github.com/alvarosg","followers_url":"https://api.github.com/users/alvarosg/followers","following_url":"https://api.github.com/users/alvarosg/following{/other_user}","gists_url":"https://api.github.com/users/alvarosg/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosg/subscriptions","organizations_url":"https://api.github.com/users/alvarosg/orgs","repos_url":"https://api.github.com/users/alvarosg/repos","events_url":"https://api.github.com/users/alvarosg/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosg/received_events","type":"User","site_admin":false},"body":"This PR is part of a [larger PR](https://github.com/matplotlib/matplotlib/pull/7294) originally proposed to include FuncNorm and PiecewiseNorm. It was decided to split it into several PRs for easier review starting from the simpler classes.\r\n\r\nIn this case the functionality added is `FuncNorm`, a normalization class (inheriting from `Normalize`), that allows using any arbitrary function as a normalization, by specifying a callable (and a callable of the inverse function), or a string compatible with the brand new `_StringFuncParser`.\r\n\r\nExamples of usage for log normalization:\r\n```python\r\n    norm_log = colors.FuncNorm(f='log10', vmin=0.01)\r\n```\r\nthe same can be achieved with\r\n```python\r\n    norm_log = colors.FuncNorm(f=np.log10,\r\n                               finv=lambda x: 10.**(x), vmin=0.01)\r\n```\r\n\r\nFor root normalization:\r\n```python\r\n    norm_sqrt = colors.FuncNorm(f='sqrt', vmin=0.0)\r\n```\r\nthe same can be achieved with\r\n```python\r\n    norm_sqrt = colors.FuncNorm(f='root{2}', vmin=0.)\r\n```\r\nor with\r\n```python\r\n    norm_sqrt = colors.FuncNorm(f=lambda x: x**0.5,\r\n                                finv=lambda x: x**2, vmin=0.0)\r\n```\r\n\r\nTests have been added, as well as an example producing this output this output:\r\n\r\n![funcnorm](https://cloud.githubusercontent.com/assets/12649253/21247164/5bf181b0-c325-11e6-8574-36a10c752fda.png)\r\n\r\n\r\nPossible caveat:\r\n\r\nMost of the behaviour provided by this class does not change the existing interfaces for normalizations, as most public methods of the new class are just overridden methods from `Normalize`.\r\n\r\nThe only exception to this is the ticks methods, returning an educated guess on where to add tick values, which would be a new public method in the class. \r\n\r\nOn the other hand I think it works quite well (even for very non-linear normalizations) and it is important to give the user a good guess at where to put the ticks, so it is not required to manually enter values (or come up with his own automated algorithm). This way the only thing the user needs to specify is a number of ticks, which may also be easily set to a default value. We should think whether we want to include this or no, or maybe do it in a different way.\r\n\r\nThe way it is done now is by an explicit call to `norm.ticks()`:\r\n\r\n```python\r\nfig.colorbar(cax, format='%.3g', ticks=cax.norm.ticks(5), ax=ax2)\r\n```\r\n\r\n\r\n\r\n\r\n\r\n","created_at":"2016-12-16T00:35:48Z","updated_at":"2016-12-16T19:51:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb257dc0d496aff3094a5051616664df3231ed6e","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631/commits","review_comments_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631/comments","review_comment_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments{/number}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/7631/comments","statuses_url":"https://api.github.com/repos/matplotlib/matplotlib/statuses/0ffcb7253df571107bf7e1c933849f3d6e9eb46c","head":{"label":"alvarosg:func-norm","ref":"func-norm","sha":"0ffcb7253df571107bf7e1c933849f3d6e9eb46c","user":{"login":"alvarosg","id":12649253,"avatar_url":"https://avatars.githubusercontent.com/u/12649253?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosg","html_url":"https://github.com/alvarosg","followers_url":"https://api.github.com/users/alvarosg/followers","following_url":"https://api.github.com/users/alvarosg/following{/other_user}","gists_url":"https://api.github.com/users/alvarosg/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosg/subscriptions","organizations_url":"https://api.github.com/users/alvarosg/orgs","repos_url":"https://api.github.com/users/alvarosg/repos","events_url":"https://api.github.com/users/alvarosg/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosg/received_events","type":"User","site_admin":false},"repo":{"id":71148616,"name":"matplotlib","full_name":"alvarosg/matplotlib","owner":{"login":"alvarosg","id":12649253,"avatar_url":"https://avatars.githubusercontent.com/u/12649253?v=3","gravatar_id":"","url":"https://api.github.com/users/alvarosg","html_url":"https://github.com/alvarosg","followers_url":"https://api.github.com/users/alvarosg/followers","following_url":"https://api.github.com/users/alvarosg/following{/other_user}","gists_url":"https://api.github.com/users/alvarosg/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarosg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarosg/subscriptions","organizations_url":"https://api.github.com/users/alvarosg/orgs","repos_url":"https://api.github.com/users/alvarosg/repos","events_url":"https://api.github.com/users/alvarosg/events{/privacy}","received_events_url":"https://api.github.com/users/alvarosg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alvarosg/matplotlib","description":"matplotlib: plotting with Python","fork":true,"url":"https://api.github.com/repos/alvarosg/matplotlib","forks_url":"https://api.github.com/repos/alvarosg/matplotlib/forks","keys_url":"https://api.github.com/repos/alvarosg/matplotlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alvarosg/matplotlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alvarosg/matplotlib/teams","hooks_url":"https://api.github.com/repos/alvarosg/matplotlib/hooks","issue_events_url":"https://api.github.com/repos/alvarosg/matplotlib/issues/events{/number}","events_url":"https://api.github.com/repos/alvarosg/matplotlib/events","assignees_url":"https://api.github.com/repos/alvarosg/matplotlib/assignees{/user}","branches_url":"https://api.github.com/repos/alvarosg/matplotlib/branches{/branch}","tags_url":"https://api.github.com/repos/alvarosg/matplotlib/tags","blobs_url":"https://api.github.com/repos/alvarosg/matplotlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alvarosg/matplotlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alvarosg/matplotlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/alvarosg/matplotlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alvarosg/matplotlib/statuses/{sha}","languages_url":"https://api.github.com/repos/alvarosg/matplotlib/languages","stargazers_url":"https://api.github.com/repos/alvarosg/matplotlib/stargazers","contributors_url":"https://api.github.com/repos/alvarosg/matplotlib/contributors","subscribers_url":"https://api.github.com/repos/alvarosg/matplotlib/subscribers","subscription_url":"https://api.github.com/repos/alvarosg/matplotlib/subscription","commits_url":"https://api.github.com/repos/alvarosg/matplotlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/alvarosg/matplotlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/alvarosg/matplotlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/alvarosg/matplotlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/alvarosg/matplotlib/contents/{+path}","compare_url":"https://api.github.com/repos/alvarosg/matplotlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alvarosg/matplotlib/merges","archive_url":"https://api.github.com/repos/alvarosg/matplotlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alvarosg/matplotlib/downloads","issues_url":"https://api.github.com/repos/alvarosg/matplotlib/issues{/number}","pulls_url":"https://api.github.com/repos/alvarosg/matplotlib/pulls{/number}","milestones_url":"https://api.github.com/repos/alvarosg/matplotlib/milestones{/number}","notifications_url":"https://api.github.com/repos/alvarosg/matplotlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alvarosg/matplotlib/labels{/name}","releases_url":"https://api.github.com/repos/alvarosg/matplotlib/releases{/id}","deployments_url":"https://api.github.com/repos/alvarosg/matplotlib/deployments","created_at":"2016-10-17T14:43:32Z","updated_at":"2016-10-17T14:43:42Z","pushed_at":"2016-12-16T00:13:28Z","git_url":"git://github.com/alvarosg/matplotlib.git","ssh_url":"git@github.com:alvarosg/matplotlib.git","clone_url":"https://github.com/alvarosg/matplotlib.git","svn_url":"https://github.com/alvarosg/matplotlib","homepage":"http://matplotlib.org/","size":295771,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"matplotlib:master","ref":"master","sha":"841a427620560bb13d218382a041fe4c4d38b730","user":{"login":"matplotlib","id":215947,"avatar_url":"https://avatars.githubusercontent.com/u/215947?v=3","gravatar_id":"","url":"https://api.github.com/users/matplotlib","html_url":"https://github.com/matplotlib","followers_url":"https://api.github.com/users/matplotlib/followers","following_url":"https://api.github.com/users/matplotlib/following{/other_user}","gists_url":"https://api.github.com/users/matplotlib/gists{/gist_id}","starred_url":"https://api.github.com/users/matplotlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matplotlib/subscriptions","organizations_url":"https://api.github.com/users/matplotlib/orgs","repos_url":"https://api.github.com/users/matplotlib/repos","events_url":"https://api.github.com/users/matplotlib/events{/privacy}","received_events_url":"https://api.github.com/users/matplotlib/received_events","type":"Organization","site_admin":false},"repo":{"id":1385122,"name":"matplotlib","full_name":"matplotlib/matplotlib","owner":{"login":"matplotlib","id":215947,"avatar_url":"https://avatars.githubusercontent.com/u/215947?v=3","gravatar_id":"","url":"https://api.github.com/users/matplotlib","html_url":"https://github.com/matplotlib","followers_url":"https://api.github.com/users/matplotlib/followers","following_url":"https://api.github.com/users/matplotlib/following{/other_user}","gists_url":"https://api.github.com/users/matplotlib/gists{/gist_id}","starred_url":"https://api.github.com/users/matplotlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matplotlib/subscriptions","organizations_url":"https://api.github.com/users/matplotlib/orgs","repos_url":"https://api.github.com/users/matplotlib/repos","events_url":"https://api.github.com/users/matplotlib/events{/privacy}","received_events_url":"https://api.github.com/users/matplotlib/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/matplotlib/matplotlib","description":"matplotlib: plotting with Python","fork":false,"url":"https://api.github.com/repos/matplotlib/matplotlib","forks_url":"https://api.github.com/repos/matplotlib/matplotlib/forks","keys_url":"https://api.github.com/repos/matplotlib/matplotlib/keys{/key_id}","collaborators_url":"https://api.github.com/repos/matplotlib/matplotlib/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/matplotlib/matplotlib/teams","hooks_url":"https://api.github.com/repos/matplotlib/matplotlib/hooks","issue_events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/events{/number}","events_url":"https://api.github.com/repos/matplotlib/matplotlib/events","assignees_url":"https://api.github.com/repos/matplotlib/matplotlib/assignees{/user}","branches_url":"https://api.github.com/repos/matplotlib/matplotlib/branches{/branch}","tags_url":"https://api.github.com/repos/matplotlib/matplotlib/tags","blobs_url":"https://api.github.com/repos/matplotlib/matplotlib/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/matplotlib/matplotlib/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/matplotlib/matplotlib/git/refs{/sha}","trees_url":"https://api.github.com/repos/matplotlib/matplotlib/git/trees{/sha}","statuses_url":"https://api.github.com/repos/matplotlib/matplotlib/statuses/{sha}","languages_url":"https://api.github.com/repos/matplotlib/matplotlib/languages","stargazers_url":"https://api.github.com/repos/matplotlib/matplotlib/stargazers","contributors_url":"https://api.github.com/repos/matplotlib/matplotlib/contributors","subscribers_url":"https://api.github.com/repos/matplotlib/matplotlib/subscribers","subscription_url":"https://api.github.com/repos/matplotlib/matplotlib/subscription","commits_url":"https://api.github.com/repos/matplotlib/matplotlib/commits{/sha}","git_commits_url":"https://api.github.com/repos/matplotlib/matplotlib/git/commits{/sha}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/comments{/number}","issue_comment_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments{/number}","contents_url":"https://api.github.com/repos/matplotlib/matplotlib/contents/{+path}","compare_url":"https://api.github.com/repos/matplotlib/matplotlib/compare/{base}...{head}","merges_url":"https://api.github.com/repos/matplotlib/matplotlib/merges","archive_url":"https://api.github.com/repos/matplotlib/matplotlib/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/matplotlib/matplotlib/downloads","issues_url":"https://api.github.com/repos/matplotlib/matplotlib/issues{/number}","pulls_url":"https://api.github.com/repos/matplotlib/matplotlib/pulls{/number}","milestones_url":"https://api.github.com/repos/matplotlib/matplotlib/milestones{/number}","notifications_url":"https://api.github.com/repos/matplotlib/matplotlib/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/labels{/name}","releases_url":"https://api.github.com/repos/matplotlib/matplotlib/releases{/id}","deployments_url":"https://api.github.com/repos/matplotlib/matplotlib/deployments","created_at":"2011-02-19T03:17:12Z","updated_at":"2016-12-16T18:33:00Z","pushed_at":"2016-12-16T01:50:22Z","git_url":"git://github.com/matplotlib/matplotlib.git","ssh_url":"git@github.com:matplotlib/matplotlib.git","clone_url":"https://github.com/matplotlib/matplotlib.git","svn_url":"https://github.com/matplotlib/matplotlib","homepage":"http://matplotlib.org/","size":295708,"stargazers_count":4485,"watchers_count":4485,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2200,"mirror_url":null,"open_issues_count":1033,"forks":2200,"open_issues":1033,"watchers":4485,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631"},"html":{"href":"https://github.com/matplotlib/matplotlib/pull/7631"},"issue":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/7631"},"comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/issues/7631/comments"},"review_comments":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631/comments"},"review_comment":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/matplotlib/matplotlib/pulls/7631/commits"},"statuses":{"href":"https://api.github.com/repos/matplotlib/matplotlib/statuses/0ffcb7253df571107bf7e1c933849f3d6e9eb46c"}}}}
{"actor":{"display_login":"story645"}}