Title: Unnecessarily large date range created when plotting a single point using a Datetime object · Issue #5963 · matplotlib/matplotlib · GitHub
Open Graph Title: Unnecessarily large date range created when plotting a single point using a Datetime object · Issue #5963 · matplotlib/matplotlib
X Title: Unnecessarily large date range created when plotting a single point using a Datetime object · Issue #5963 · matplotlib/matplotlib
Description: As explained in my original StackOverflow question, I've found some unexpected behavior when plotting single points in matplotlib.pyplot with Datetime objects. Plotting multiple points (>1) gives the range of dates with some buffer on ei...
Open Graph Description: As explained in my original StackOverflow question, I've found some unexpected behavior when plotting single points in matplotlib.pyplot with Datetime objects. Plotting multiple points (>1) gives t...
X Description: As explained in my original StackOverflow question, I've found some unexpected behavior when plotting single points in matplotlib.pyplot with Datetime objects. Plotting multiple points (>1) ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/5963
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unnecessarily large date range created when plotting a single point using a Datetime object","articleBody":"As explained in my original StackOverflow [question](http://stackoverflow.com/q/35163031/4739755), I've found some unexpected behavior when plotting single points in matplotlib.pyplot with Datetime objects. Plotting multiple points (\u003e1) gives the range of dates with some buffer on either side. Plotting a single point causes the range to span multiple years (2014 - 2018 using Feb 03, 2016).\n\nWhen using the AutoDateLocator(), the (assumed) issue isn't as noticeable since the generated ticks are fairly conservative, but using a WeekdayLocator() instead results in a dense mess of ticks. The application I'm using this for deals with time spans of _at most_ a few months, so suddenly getting a range of multiple _years_ is quite jarring.\n\nBelow is some code that generates 6 matplotlib.pyplot plot images to demonstrate a few example cases and the output from running the script with the --verbose-debug flag\n\n```\nimport matplotlib.pyplot as plt\nimport matplotlib.dates as md\nfrom datetime import datetime\n\n# Create figures\nfig0 = plt.figure(0)\nfig1 = plt.figure(1)\nfig2 = plt.figure(2)\nfig3 = plt.figure(3)\nfig4 = plt.figure(4)\nfig5 = plt.figure(5)\nfig6 = plt.figure(6)\n# Add some subplots\nsub3 = fig3.add_subplot(111)\nsub4 = fig4.add_subplot(111)\nsub5 = fig5.add_subplot(111)\nsub6 = fig6.add_subplot(111)\n\n# Creating a regular plot directly with a single point\nplt.figure(0)\nplt.plot((2,), (3,), marker='o')\nplt.title('Regular plot, single point')\n\n# Doing the same, but with a subplot\nsub3.plot((2,), (3,), marker='o')\nsub3.set_title('Subplot, single point')\n\n# Creating a regular plot using a Datetime object with multiple points\n# Using the AutoDateLocator()\ntest_date_one = datetime.strptime('2016-02-03', '%Y-%m-%d')\ntest_date_two = datetime.strptime('2016-03-03', '%Y-%m-%d')\n\nplt.figure(1)\nplt.plot((test_date_one, test_date_two), (2, 3), marker='o')\nfig1.autofmt_xdate()\nplt.title('Regular plot, multiple Datetime points')\n\n# Now with a single point\nplt.figure(2)\nplt.plot(test_date_one, 2, marker='o')\nfig2.autofmt_xdate()\nplt.title('Regular plot, single Datetime point')\n\n# Doing the same, but with a subplot\n# Multiple points\nsub4.plot((test_date_one, test_date_two), (2, 3), marker='o')\nfig4.autofmt_xdate()\nsub4.set_title('Subplot, multiple Datetime points')\n\n# Single point\nsub5.plot(test_date_one, 2, marker='o')\nfig5.autofmt_xdate()\nsub5.set_title('Subplot, single Datetime point')\n\n# Finally, single Datetime point with WeekdayLocator()\nsub6.plot(test_date_two, 3, marker='o')\nsub6.xaxis.set_major_locator(md.WeekdayLocator())\nfig6.autofmt_xdate()\nsub6.set_title('Subplot, single Datetime point, WeekdayLocator()')\n\nplt.show()\n```\n\n**Debug Output**\n$HOME=C:\\Users******\\\nmatplotlib data path C:\\Python27\\lib\\site-packages\\matplotlib\\mpl-data\n\n---\n\nYou have the following UNSUPPORTED LaTeX preamble customizations:\n\nPlease do not ask for support with these customizations active.\n\n---\n\nloaded rc file C:\\Python27\\lib\\site-packages\\matplotlib\\mpl-data\\matplotlibrc\nmatplotlib version 1.5.1\nverbose.level debug\ninteractive is False\nplatform is win32\nloaded modules: \u003cdictionary-keyiterator object at 0x04E08810\u003e\nCACHEDIR=C:\\Users\\******\\.matplotlib\nUsing fontManager instance from C:\\Users\\******\\.matplotlib\\fontList.cache\nbackend TkAgg version 8.5\nCould not load matplotlib icon: can't use \"pyimage10\" as iconphoto: not a photo image\nCould not load matplotlib icon: can't use \"pyimage19\" as iconphoto: not a photo image\nCould not load matplotlib icon: can't use \"pyimage28\" as iconphoto: not a photo image\nCould not load matplotlib icon: can't use \"pyimage37\" as iconphoto: not a photo image\nCould not load matplotlib icon: can't use \"pyimage46\" as iconphoto: not a photo image\nCould not load matplotlib icon: can't use \"pyimage55\" as iconphoto: not a photo image\nfindfont: Matching :family=sans-serif:style=normal:variant=normal:weight=400:stretch=normal:size=medium to Bitstream Vera Sans (u'c:\\python27\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf') with score of 0.000000\nfindfont: Matching :family=sans-serif:style=normal:variant=normal:weight=400:stretch=normal:size=large to Bitstream Vera Sans (u'c:\\python27\\lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\Vera.ttf') with score of 0.000000\n","author":{"url":"https://github.com/bcoov","@type":"Person","name":"bcoov"},"datePublished":"2016-02-03T17:12:56.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":15},"url":"https://github.com/5963/matplotlib/issues/5963"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:418ac876-1318-c936-7cc2-b5274f291618 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 81A6:108FC:F0DCB7:14382DF:6A532F02 |
| html-safe-nonce | 5af2ad288d4f2478a5bb91ab470a5898f005bc0f6e99ab17763420fbd817ad13 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MUE2OjEwOEZDOkYwRENCNzoxNDM4MkRGOjZBNTMyRjAyIiwidmlzaXRvcl9pZCI6Ijg1MzYwOTgxNDUwOTYxMTgwMTgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fba0b37fb1b7b305a1f63254996a3b9bc034e490b20864fc696a95a6b860b288 |
| hovercard-subject-tag | issue:131091461 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/5963/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e2e356588d20dbcfed4f0f01209fa0da3dcd012ef8423f2fc7841d9067fd7a14/matplotlib/matplotlib/issues/5963 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e2e356588d20dbcfed4f0f01209fa0da3dcd012ef8423f2fc7841d9067fd7a14/matplotlib/matplotlib/issues/5963 |
| og:image:alt | As explained in my original StackOverflow question, I've found some unexpected behavior when plotting single points in matplotlib.pyplot with Datetime objects. Plotting multiple points (>1) gives t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bcoov |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width