{"action":"opened","issue":{"url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4916","labels_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4916/labels{/name}","comments_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4916/comments","events_url":"https://api.github.com/repos/matplotlib/matplotlib/issues/4916/events","html_url":"https://github.com/matplotlib/matplotlib/issues/4916","id":100858794,"number":4916,"title":"Cannot use a timedelta Rectangle width with a datetime axis","user":{"login":"brandon-rhodes","id":166162,"avatar_url":"https://avatars.githubusercontent.com/u/166162?v=3","gravatar_id":"","url":"https://api.github.com/users/brandon-rhodes","html_url":"https://github.com/brandon-rhodes","followers_url":"https://api.github.com/users/brandon-rhodes/followers","following_url":"https://api.github.com/users/brandon-rhodes/following{/other_user}","gists_url":"https://api.github.com/users/brandon-rhodes/gists{/gist_id}","starred_url":"https://api.github.com/users/brandon-rhodes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brandon-rhodes/subscriptions","organizations_url":"https://api.github.com/users/brandon-rhodes/orgs","repos_url":"https://api.github.com/users/brandon-rhodes/repos","events_url":"https://api.github.com/users/brandon-rhodes/events{/privacy}","received_events_url":"https://api.github.com/users/brandon-rhodes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-13T20:15:20Z","updated_at":"2015-08-13T20:15:20Z","closed_at":null,"body":"I would like to draw a rectangle to represent the weekend on a plot whose x-axis is time. In an IPython Notebook:\r\n```\r\n%pylab inline\r\ndt = datetime.datetime\r\ndates = [\r\n    dt(2015, 1, 1),\r\n    dt(2015, 1, 2),\r\n    dt(2015, 1, 3),\r\n    dt(2015, 1, 4),\r\n    dt(2015, 1, 5),\r\n    ]\r\ndata = [56.0, 53.2, 57.8, 59.1, 55.5]\r\ngca().add_patch(Rectangle(\r\n    xy=(dt(2015, 1, 3), 50.0),\r\n    width=datetime.timedelta(days=2), \r\n    height=1.0,\r\n    ))\r\nplot(dates, data)\r\n```\r\nThe big problem is that the above code dies with an exception.\r\n```\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-13-b4545adc3ff2> in <module>()\r\n     12     xy=(dt(2015, 1, 3), 50.0),\r\n     13     width=datetime.timedelta(days=2),\r\n---> 14     height=1.0,\r\n     15     ))\r\n     16 plot(dates, data)\r\n\r\n...\r\n\r\n/home/brhodes/.v/misc/lib/python2.7/site-packages/matplotlib/dates.pyc in _to_ordinalf(dt)\r\n    202             dt -= delta\r\n    203 \r\n--> 204     base = float(dt.toordinal())\r\n    205     if hasattr(dt, 'hour'):\r\n    206         base += (dt.hour / HOURS_PER_DAY + dt.minute / MINUTES_PER_DAY +\r\n\r\nAttributeError: 'datetime.timedelta' object has no attribute 'toordinal'\r\n```\r\n\r\nThe other problem is that my backup plan, of replacing the `timedelta()` with the floating-point value 2.0, destroys the date-ness of the `x` axis. It reverts to being a float that does not display as a date.\r\n\r\nWhy is a `timedelta` not a valid increment or offset with which I can express width along a datetime x-axis?\r\n\r\nThanks for any help you can provide!"}}