{"action":"created","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5557","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5557/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5557/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5557/events","html_url":"https://github.com/matplotlib/matplotlib/issues/5557","id":118704830,"number":5557,"title":"plt.hist throws KeyError when passed a pandas.Series without 0 in index","user":{"login":"8one6","id":4360170,"avatar_url":"https://avatars.githubusercontent.com/u/4360170?v=3","gravatar_id":"","url":"https://api.github.com/users/8one6","html_url":"https://github.com/8one6","followers_url":"https://api.github.com/users/8one6/followers","following_url":"https://api.github.com/users/8one6/following{/other_user}","gists_url":"https://api.github.com/users/8one6/gists{/gist_id}","starred_url":"https://api.github.com/users/8one6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8one6/subscriptions","organizations_url":"https://api.github.com/users/8one6/orgs","repos_url":"https://api.github.com/users/8one6/repos","events_url":"https://api.github.com/users/8one6/events{/privacy}","received_events_url":"https://api.github.com/users/8one6/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-24T21:18:25Z","updated_at":"2015-12-07T14:30:58Z","closed_at":null,"body":"```python\r\nimport pandas as pd\r\nimport matplotlib.pyplot as plt\r\n\r\nser_1 = pd.Series(data=[1, 2, 2, 3, 3, 4, 4, 4, 4, 5])\r\nser_2 = ser_1.iloc[1:]\r\nfig, axes = plt.subplots(1, 4, figsize=(16, 4))\r\naxes[0].hist(ser_1.values)\r\naxes[1].hist(ser_1)\r\naxes[2].hist(ser_2.values)\r\naxes[3].hist(ser_2)\r\n```\r\n\r\nThis snipped correctly plots in the first three cases, but errors in the last case, saying (in the relevant part):\r\n```python\r\n/venv/local/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc\r\nin hist(self, x, bins, range, normed, weights, cumulative, bottom, histtype, \r\nalign, orientation, rwidth, log, color, label, stacked, **kwargs)\r\n   5602         # Massage 'x' for processing.\r\n   5603         # NOTE: Be sure any changes here is also done below to 'weights'\r\n-> 5604         if isinstance(x, np.ndarray) or not iterable(x[0]):\r\n   5605             # TODO: support masked arrays;\r\n   5606             x = np.asarray(x)\r\n```\r\n(which then descends into a KeyError in the bowels of pandas).\r\n\r\nSo seems like the issue here is that `x[0]` is being used to find the first element of the input data (which would work fine if the input data is a `numpy.ndarray`).  But in this case `x` is a `pandas.Series` and as a result `x[0]` is an index lookup rather than a normal slice.  This works fine on `axes[1]` since in that case the histogrammed series includes `0` in its index.  However, on `axes[3]`, the histogrammed data no longer includes `0` in the index and things fall apart.\r\n"},"comment":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/comments/162540418","html_url":"https://github.com/matplotlib/matplotlib/issues/5557#issuecomment-162540418","issue_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/5557","id":162540418,"user":{"login":"8one6","id":4360170,"avatar_url":"https://avatars.githubusercontent.com/u/4360170?v=3","gravatar_id":"","url":"https://api.github.com/users/8one6","html_url":"https://github.com/8one6","followers_url":"https://api.github.com/users/8one6/followers","following_url":"https://api.github.com/users/8one6/following{/other_user}","gists_url":"https://api.github.com/users/8one6/gists{/gist_id}","starred_url":"https://api.github.com/users/8one6/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/8one6/subscriptions","organizations_url":"https://api.github.com/users/8one6/orgs","repos_url":"https://api.github.com/users/8one6/repos","events_url":"https://api.github.com/users/8one6/events{/privacy}","received_events_url":"https://api.github.com/users/8one6/received_events","type":"User","site_admin":false},"created_at":"2015-12-07T14:30:58Z","updated_at":"2015-12-07T14:30:58Z","body":"xref #5550"}}