{"action":"created","comment":{"url":"https://api.github.com/repos/xray/xray/pulls/comments/34943981","id":34943981,"diff_hunk":"@@ -0,0 +1,366 @@\n+Plotting\n+========\n+\n+Introduction\n+------------\n+\n+The goal of xray's plotting is to make exploratory plotting quick\n+and easy by using metadata from :py:class:`xray.DataArray` objects to add\n+informative labels.\n+\n+Xray plotting functionality is a thin wrapper around the popular\n+`matplotlib <http://matplotlib.org/>`_ library.\n+Matplotlib syntax and function names were copied as much as possible, which\n+makes for an easy transition between the two.\n+Matplotlib must be installed and working before plotting with xray.\n+\n+For more extensive plotting applications consider the following projects:\n+\n+- `Seaborn <http://stanford.edu/~mwaskom/software/seaborn/>`_: \"provides\n+  a high-level interface for drawing attractive statistical graphics.\"\n+  Integrates well with pandas.\n+\n+- `Holoviews <http://ioam.github.io/holoviews/>`_: \"Composable, declarative\n+  data structures for building even complex visualizations easily.\" Works\n+  for 2d datasets.\n+\n+- `Cartopy <http://scitools.org.uk/cartopy/>`_: Provides cartographic\n+  tools.\n+\n+Imports\n+~~~~~~~\n+\n+.. ipython:: python\n+\n+    # Use defaults so we don't get gridlines in generated docs\n+    import matplotlib as mpl\n+    mpl.rcdefaults()\n+\n+The following imports are necessary for all of the examples.\n+\n+.. ipython:: python\n+\n+    import numpy as np\n+    import matplotlib.pyplot as plt\n+    import xray\n+\n+One Dimension\n+-------------\n+\n+Simple Example\n+~~~~~~~~~~~~~~\n+\n+Xray uses the coordinate name to label the x axis:\n+\n+.. ipython:: python\n+\n+    t = np.linspace(0, np.pi, num=20)\n+    sinpts = xray.DataArray(np.sin(t), {'t': t}, name='sin(t)')\n+    sinpts\n+\n+    @savefig plotting_example_sin.png width=4in\n+    sinpts.plot()\n+\n+Additional Arguments\n+~~~~~~~~~~~~~~~~~~~~~\n+\n+Additional arguments are passed directly to the matplotlib function which\n+does the work.\n+For example, :py:meth:`xray.DataArray.plot_line` calls \n+matplotlib.pyplot.plot_ passing in the index and the array values as x and y, respectively.\n+So to make a line plot with blue triangles a matplotlib format string\n+can be used:\n+\n+.. _matplotlib.pyplot.plot: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.plot\n+\n+.. ipython:: python\n+\n+    @savefig plotting_example_sin2.png width=4in\n+    sinpts.plot_line('b-^')\n+\n+.. warning::\n+    Not all xray plotting methods support passing positional arguments\n+    to the wrapped matplotlib functions, but they do all\n+    support keyword arguments.\n+\n+Keyword arguments work the same way, and are more explicit.\n+\n+.. ipython:: python\n+\n+    @savefig plotting_example_sin3.png width=4in\n+    sinpts.plot_line(color='purple', marker='o')\n+\n+Adding to Existing Axis\n+~~~~~~~~~~~~~~~~~~~~~~~\n+\n+To add the plot to an existing axis pass in the axis as a keyword argument\n+``ax``. This works for all xray plotting methods.\n+In this example ``axes`` is a tuple consisting of the left and right\n+axes created by ``plt.subplots``.\n+\n+.. ipython:: python\n+\n+    fig, axes = plt.subplots(ncols=2)\n+\n+    axes\n+\n+    sinpts.plot(ax=axes[0])\n+    sinpts.plot_hist(ax=axes[1])\n+\n+    @savefig plotting_example_existing_axes.png width=6in\n+    plt.show()\n+\n+On the right is a histogram created by :py:meth:`xray.DataArray.plot_hist`.\n+\n+Time Series\n+~~~~~~~~~~~\n+\n+The index may be a date.\n+\n+.. ipython:: python\n+\n+    import pandas as pd\n+    npts = 20\n+    time = pd.date_range('2015-01-01', periods=npts)\n+    noise = xray.DataArray(np.random.randn(npts), {'time': time})\n+\n+    @savefig plotting_example_time.png width=6in\n+    noise.plot_line()\n+\n+TODO- rotate dates printed on x axis.","path":"doc/plotting.rst","position":130,"original_position":130,"commit_id":"9a54bedee07643d7ada5f13bab64696cadbab587","original_commit_id":"9a54bedee07643d7ada5f13bab64696cadbab587","user":{"login":"clarkfitzg","id":5356122,"avatar_url":"https://avatars.githubusercontent.com/u/5356122?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkfitzg","html_url":"https://github.com/clarkfitzg","followers_url":"https://api.github.com/users/clarkfitzg/followers","following_url":"https://api.github.com/users/clarkfitzg/following{/other_user}","gists_url":"https://api.github.com/users/clarkfitzg/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkfitzg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkfitzg/subscriptions","organizations_url":"https://api.github.com/users/clarkfitzg/orgs","repos_url":"https://api.github.com/users/clarkfitzg/repos","events_url":"https://api.github.com/users/clarkfitzg/events{/privacy}","received_events_url":"https://api.github.com/users/clarkfitzg/received_events","type":"User","site_admin":false},"body":"This isn't plotting well.","created_at":"2015-07-18T04:06:11Z","updated_at":"2015-07-18T04:06:11Z","html_url":"https://github.com/xray/xray/pull/466#discussion_r34943981","pull_request_url":"https://api.github.com/repos/xray/xray/pulls/466","_links":{"self":{"href":"https://api.github.com/repos/xray/xray/pulls/comments/34943981"},"html":{"href":"https://github.com/xray/xray/pull/466#discussion_r34943981"},"pull_request":{"href":"https://api.github.com/repos/xray/xray/pulls/466"}}},"pull_request":{"url":"https://api.github.com/repos/xray/xray/pulls/466","id":39735619,"html_url":"https://github.com/xray/xray/pull/466","diff_url":"https://github.com/xray/xray/pull/466.diff","patch_url":"https://github.com/xray/xray/pull/466.patch","issue_url":"https://api.github.com/repos/xray/xray/issues/466","number":466,"state":"open","locked":false,"title":"Feature plotting","user":{"login":"clarkfitzg","id":5356122,"avatar_url":"https://avatars.githubusercontent.com/u/5356122?v=3","gravatar_id":"","url":"https://api.github.com/users/clarkfitzg","html_url":"https://github.com/clarkfitzg","followers_url":"https://api.github.com/users/clarkfitzg/followers","following_url":"https://api.github.com/users/clarkfitzg/following{/other_user}","gists_url":"https://api.github.com/users/clarkfitzg/gists{/gist_id}","starred_url":"https://api.github.com/users/clarkfitzg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clarkfitzg/subscriptions","organizations_url":"https://api.github.com/users/clarkfitzg/orgs","repos_url":"https://api.github.com/users/clarkfitzg/repos","events_url":"https://api.github.com/users/clarkfitzg/events{/privacy}","received_events_url":"https://api.github.com/users/clarkfitzg/received_events","type":"User","site_admin":false},"body":"Not complete, but still ready for some feedback!\r\n\r\nDocs are built here:\r\nhttp://xray.readthedocs.org/en/feature-plotting/plotting.html\r\n\r\nThere are several TODOs around the docs and the code base. For some of these I'm requesting specific feedback.\r\n\r\nStill need to:\r\n- Handle NaN's\r\n- Informative TypeError for coords that can't be plotted","created_at":"2015-07-11T00:18:51Z","updated_at":"2015-07-18T04:06:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"125cb7b3141046643d0a8636aba06a55504a8c25","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/xray/xray/pulls/466/commits","review_comments_url":"https://api.github.com/repos/xray/xray/pulls/466/comments","review_comment_url":"https://api.github.com/repos/xray/xray/pulls/comments{/number}","comments_url":"https://api.github.com/repos/xray/xray/issues/466/comments","statuses_url":"https://api.github.com/repos/xray/xray/statuses/9a54bedee07643d7ada5f13bab64696cadbab587","head":{"label":"xray:feature-plotting","ref":"feature-plotting","sha":"9a54bedee07643d7ada5f13bab64696cadbab587","user":{"login":"xray","id":7505795,"avatar_url":"https://avatars.githubusercontent.com/u/7505795?v=3","gravatar_id":"","url":"https://api.github.com/users/xray","html_url":"https://github.com/xray","followers_url":"https://api.github.com/users/xray/followers","following_url":"https://api.github.com/users/xray/following{/other_user}","gists_url":"https://api.github.com/users/xray/gists{/gist_id}","starred_url":"https://api.github.com/users/xray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xray/subscriptions","organizations_url":"https://api.github.com/users/xray/orgs","repos_url":"https://api.github.com/users/xray/repos","events_url":"https://api.github.com/users/xray/events{/privacy}","received_events_url":"https://api.github.com/users/xray/received_events","type":"Organization","site_admin":false},"repo":{"id":13221727,"name":"xray","full_name":"xray/xray","owner":{"login":"xray","id":7505795,"avatar_url":"https://avatars.githubusercontent.com/u/7505795?v=3","gravatar_id":"","url":"https://api.github.com/users/xray","html_url":"https://github.com/xray","followers_url":"https://api.github.com/users/xray/followers","following_url":"https://api.github.com/users/xray/following{/other_user}","gists_url":"https://api.github.com/users/xray/gists{/gist_id}","starred_url":"https://api.github.com/users/xray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xray/subscriptions","organizations_url":"https://api.github.com/users/xray/orgs","repos_url":"https://api.github.com/users/xray/repos","events_url":"https://api.github.com/users/xray/events{/privacy}","received_events_url":"https://api.github.com/users/xray/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xray/xray","description":"N-D labeled arrays and datasets in Python","fork":false,"url":"https://api.github.com/repos/xray/xray","forks_url":"https://api.github.com/repos/xray/xray/forks","keys_url":"https://api.github.com/repos/xray/xray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xray/xray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xray/xray/teams","hooks_url":"https://api.github.com/repos/xray/xray/hooks","issue_events_url":"https://api.github.com/repos/xray/xray/issues/events{/number}","events_url":"https://api.github.com/repos/xray/xray/events","assignees_url":"https://api.github.com/repos/xray/xray/assignees{/user}","branches_url":"https://api.github.com/repos/xray/xray/branches{/branch}","tags_url":"https://api.github.com/repos/xray/xray/tags","blobs_url":"https://api.github.com/repos/xray/xray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xray/xray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xray/xray/git/refs{/sha}","trees_url":"https://api.github.com/repos/xray/xray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xray/xray/statuses/{sha}","languages_url":"https://api.github.com/repos/xray/xray/languages","stargazers_url":"https://api.github.com/repos/xray/xray/stargazers","contributors_url":"https://api.github.com/repos/xray/xray/contributors","subscribers_url":"https://api.github.com/repos/xray/xray/subscribers","subscription_url":"https://api.github.com/repos/xray/xray/subscription","commits_url":"https://api.github.com/repos/xray/xray/commits{/sha}","git_commits_url":"https://api.github.com/repos/xray/xray/git/commits{/sha}","comments_url":"https://api.github.com/repos/xray/xray/comments{/number}","issue_comment_url":"https://api.github.com/repos/xray/xray/issues/comments{/number}","contents_url":"https://api.github.com/repos/xray/xray/contents/{+path}","compare_url":"https://api.github.com/repos/xray/xray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xray/xray/merges","archive_url":"https://api.github.com/repos/xray/xray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xray/xray/downloads","issues_url":"https://api.github.com/repos/xray/xray/issues{/number}","pulls_url":"https://api.github.com/repos/xray/xray/pulls{/number}","milestones_url":"https://api.github.com/repos/xray/xray/milestones{/number}","notifications_url":"https://api.github.com/repos/xray/xray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xray/xray/labels{/name}","releases_url":"https://api.github.com/repos/xray/xray/releases{/id}","created_at":"2013-09-30T17:21:10Z","updated_at":"2015-07-17T14:10:02Z","pushed_at":"2015-07-17T23:59:56Z","git_url":"git://github.com/xray/xray.git","ssh_url":"git@github.com:xray/xray.git","clone_url":"https://github.com/xray/xray.git","svn_url":"https://github.com/xray/xray","homepage":"http://xray.readthedocs.org","size":6992,"stargazers_count":196,"watchers_count":196,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":60,"forks":50,"open_issues":60,"watchers":196,"default_branch":"master"}},"base":{"label":"xray:master","ref":"master","sha":"b09c8a574aaf71f7567227b0edb5d71b9bede900","user":{"login":"xray","id":7505795,"avatar_url":"https://avatars.githubusercontent.com/u/7505795?v=3","gravatar_id":"","url":"https://api.github.com/users/xray","html_url":"https://github.com/xray","followers_url":"https://api.github.com/users/xray/followers","following_url":"https://api.github.com/users/xray/following{/other_user}","gists_url":"https://api.github.com/users/xray/gists{/gist_id}","starred_url":"https://api.github.com/users/xray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xray/subscriptions","organizations_url":"https://api.github.com/users/xray/orgs","repos_url":"https://api.github.com/users/xray/repos","events_url":"https://api.github.com/users/xray/events{/privacy}","received_events_url":"https://api.github.com/users/xray/received_events","type":"Organization","site_admin":false},"repo":{"id":13221727,"name":"xray","full_name":"xray/xray","owner":{"login":"xray","id":7505795,"avatar_url":"https://avatars.githubusercontent.com/u/7505795?v=3","gravatar_id":"","url":"https://api.github.com/users/xray","html_url":"https://github.com/xray","followers_url":"https://api.github.com/users/xray/followers","following_url":"https://api.github.com/users/xray/following{/other_user}","gists_url":"https://api.github.com/users/xray/gists{/gist_id}","starred_url":"https://api.github.com/users/xray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xray/subscriptions","organizations_url":"https://api.github.com/users/xray/orgs","repos_url":"https://api.github.com/users/xray/repos","events_url":"https://api.github.com/users/xray/events{/privacy}","received_events_url":"https://api.github.com/users/xray/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/xray/xray","description":"N-D labeled arrays and datasets in Python","fork":false,"url":"https://api.github.com/repos/xray/xray","forks_url":"https://api.github.com/repos/xray/xray/forks","keys_url":"https://api.github.com/repos/xray/xray/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xray/xray/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xray/xray/teams","hooks_url":"https://api.github.com/repos/xray/xray/hooks","issue_events_url":"https://api.github.com/repos/xray/xray/issues/events{/number}","events_url":"https://api.github.com/repos/xray/xray/events","assignees_url":"https://api.github.com/repos/xray/xray/assignees{/user}","branches_url":"https://api.github.com/repos/xray/xray/branches{/branch}","tags_url":"https://api.github.com/repos/xray/xray/tags","blobs_url":"https://api.github.com/repos/xray/xray/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xray/xray/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xray/xray/git/refs{/sha}","trees_url":"https://api.github.com/repos/xray/xray/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xray/xray/statuses/{sha}","languages_url":"https://api.github.com/repos/xray/xray/languages","stargazers_url":"https://api.github.com/repos/xray/xray/stargazers","contributors_url":"https://api.github.com/repos/xray/xray/contributors","subscribers_url":"https://api.github.com/repos/xray/xray/subscribers","subscription_url":"https://api.github.com/repos/xray/xray/subscription","commits_url":"https://api.github.com/repos/xray/xray/commits{/sha}","git_commits_url":"https://api.github.com/repos/xray/xray/git/commits{/sha}","comments_url":"https://api.github.com/repos/xray/xray/comments{/number}","issue_comment_url":"https://api.github.com/repos/xray/xray/issues/comments{/number}","contents_url":"https://api.github.com/repos/xray/xray/contents/{+path}","compare_url":"https://api.github.com/repos/xray/xray/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xray/xray/merges","archive_url":"https://api.github.com/repos/xray/xray/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xray/xray/downloads","issues_url":"https://api.github.com/repos/xray/xray/issues{/number}","pulls_url":"https://api.github.com/repos/xray/xray/pulls{/number}","milestones_url":"https://api.github.com/repos/xray/xray/milestones{/number}","notifications_url":"https://api.github.com/repos/xray/xray/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xray/xray/labels{/name}","releases_url":"https://api.github.com/repos/xray/xray/releases{/id}","created_at":"2013-09-30T17:21:10Z","updated_at":"2015-07-17T14:10:02Z","pushed_at":"2015-07-17T23:59:56Z","git_url":"git://github.com/xray/xray.git","ssh_url":"git@github.com:xray/xray.git","clone_url":"https://github.com/xray/xray.git","svn_url":"https://github.com/xray/xray","homepage":"http://xray.readthedocs.org","size":6992,"stargazers_count":196,"watchers_count":196,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":50,"mirror_url":null,"open_issues_count":60,"forks":50,"open_issues":60,"watchers":196,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/xray/xray/pulls/466"},"html":{"href":"https://github.com/xray/xray/pull/466"},"issue":{"href":"https://api.github.com/repos/xray/xray/issues/466"},"comments":{"href":"https://api.github.com/repos/xray/xray/issues/466/comments"},"review_comments":{"href":"https://api.github.com/repos/xray/xray/pulls/466/comments"},"review_comment":{"href":"https://api.github.com/repos/xray/xray/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/xray/xray/pulls/466/commits"},"statuses":{"href":"https://api.github.com/repos/xray/xray/statuses/9a54bedee07643d7ada5f13bab64696cadbab587"}}}}