Title: time series plotting gap causes strange jump · Issue #16266 · matplotlib/matplotlib · GitHub
Open Graph Title: time series plotting gap causes strange jump · Issue #16266 · matplotlib/matplotlib
X Title: time series plotting gap causes strange jump · Issue #16266 · matplotlib/matplotlib
Description: Bug report Gap in time series data causes MPL to jump to a very small datetime that doesnt exist in the dataset. If I don't manually set the axis, it tries to autofit. ax1.set_xlim( [ min(datana.date.dt.to_pydatetime()) , max(datana.date...
Open Graph Description: Bug report Gap in time series data causes MPL to jump to a very small datetime that doesnt exist in the dataset. If I don't manually set the axis, it tries to autofit. ax1.set_xlim( [ min(datana.da...
X Description: Bug report Gap in time series data causes MPL to jump to a very small datetime that doesnt exist in the dataset. If I don't manually set the axis, it tries to autofit. ax1.set_xlim( [ min(datan...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/16266
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"time series plotting gap causes strange jump","articleBody":"# Bug report\r\nGap in time series data causes MPL to jump to a very small datetime that doesnt exist in the dataset.\r\n\r\n\r\nIf I don't manually set the axis, it tries to autofit.\r\n```\r\nax1.set_xlim( [ min(datana.date.dt.to_pydatetime()) , max(datana.date.dt.to_pydatetime()) ])\r\n```\r\nAutofitting looks like this:\r\n\r\n\r\nNote that the minimum x datetime in the dataset is in 2019! Not sure where the 1680ish time comes from. I've manually checked what actually gets passed into mpl, a numpy object array of datetime objects, does not have a time value below 2019.\r\n\r\nAbbreviated code:\r\n```\r\nimport datetime\r\nimport time\r\nimport matplotlib\r\nmatplotlib.use(\"agg\")\r\nimport matplotlib.pyplot as plt\r\nimport pandas as pd\r\n\r\nfig1, ax1 = plt.subplots( figsize=(15,5) )\r\n\r\n data = pd.read_csv(\"temps.dat\",header=None, names=['date','temp'])\r\n data.temp = data.temp/1000\r\n data.date = pd.to_datetime(data.date)\r\n data.date = data.date.dt.ceil(freq='s') #strip microseconds\r\n data['roll'] = data['temp'].rolling(window=722 ).mean()\r\n data['roll2'] = data['temp'].rolling(window=14220 ).mean()\r\n datana = data.dropna(subset=['roll'])\r\n datana2 = data.dropna(subset=['roll2'])\r\n\r\n ax1.cla()\r\n \r\n ax1.plot(datana2.date.dt.to_pydatetime() ,datana2.roll2, lw=3, alpha=.8)\r\n ax1.plot(datana.date.dt.to_pydatetime() ,datana.roll, lw=.7)\r\n\r\n ax1.set_xlim( [ min(datana.date.dt.to_pydatetime()) , max(datana.date.dt.to_pydatetime()) ])\r\nfig1.autofmt_xdate()\r\nfig1.savefig(\"fig1.png\",format='png' ,bbox_inches='tight', dpi=500)\r\n\r\n```\r\n[temps.zip](https://github.com/matplotlib/matplotlib/files/4083375/temps.zip)\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: debian (raspbian)\r\n * Matplotlib version: 3.1.2 , in a venv, installed by pip\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): agg\r\n * Python version: 3.7\r\n \r\n * Other libraries: pandas, Pillow\r\n\r\n\r\n","author":{"url":"https://github.com/Fealthas","@type":"Person","name":"Fealthas"},"datePublished":"2020-01-19T19:21:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/16266/matplotlib/issues/16266"}
| 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:016b5e18-6bf5-6a4b-07f0-6d564e4699ef |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6B2:172D3F:3C27B70:53B26E6:6A54CC47 |
| html-safe-nonce | 497b57afe68c40a42055dc6f5c0b355c54b3718cfdb9a82943abf7b14b9cced1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkIyOjE3MkQzRjozQzI3QjcwOjUzQjI2RTY6NkE1NENDNDciLCJ2aXNpdG9yX2lkIjoiNTMwNTgzMjc0NjE5MDY4NzMwMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0aab881efab8ce362c409ffedcd535d86a478ced73645b378e5badbc8bccff5a |
| hovercard-subject-tag | issue:551970502 |
| 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/16266/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7357a3fb2c94287c63c68aacf050a92c4c242de7b37e594ffc17c128f7c55ac9/matplotlib/matplotlib/issues/16266 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7357a3fb2c94287c63c68aacf050a92c4c242de7b37e594ffc17c128f7c55ac9/matplotlib/matplotlib/issues/16266 |
| og:image:alt | Bug report Gap in time series data causes MPL to jump to a very small datetime that doesnt exist in the dataset. If I don't manually set the axis, it tries to autofit. ax1.set_xlim( [ min(datana.da... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Fealthas |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6e5f2e6ff3f430aa60a674066f957bca9f2106017e1b68126417422b58ce6e1e |
| 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 | be4d48619391052c9d312c7b587bb2ac38a97f57 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width