{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/21860","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21860/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21860/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21860/events","html_url":"https://github.com/pandas-dev/pandas/issues/21860","id":340294528,"node_id":"MDU6SXNzdWUzNDAyOTQ1Mjg=","number":21860,"title":"Indexed DataFrame.plot() prints wrong year on x-axis","user":{"login":"VOMAY","id":32896877,"node_id":"MDQ6VXNlcjMyODk2ODc3","avatar_url":"https://avatars2.githubusercontent.com/u/32896877?v=4","gravatar_id":"","url":"https://api.github.com/users/VOMAY","html_url":"https://github.com/VOMAY","followers_url":"https://api.github.com/users/VOMAY/followers","following_url":"https://api.github.com/users/VOMAY/following{/other_user}","gists_url":"https://api.github.com/users/VOMAY/gists{/gist_id}","starred_url":"https://api.github.com/users/VOMAY/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VOMAY/subscriptions","organizations_url":"https://api.github.com/users/VOMAY/orgs","repos_url":"https://api.github.com/users/VOMAY/repos","events_url":"https://api.github.com/users/VOMAY/events{/privacy}","received_events_url":"https://api.github.com/users/VOMAY/received_events","type":"User","site_admin":false},"labels":[{"id":2413328,"node_id":"MDU6TGFiZWwyNDEzMzI4","url":"https://api.github.com/repos/pandas-dev/pandas/labels/Visualization","name":"Visualization","color":"8AE234","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-11T15:30:14Z","updated_at":"2018-07-12T13:48:41Z","closed_at":null,"author_association":"NONE","body":"Input file sp3_2018X.daybound (Please copy into ASCII-file)\r\n```\r\n MJD   sec    PRN      dRad      dAlo      dCro     dRdot     dAdot     dCdot\r\n                       (mm)      (mm)      (mm)    (mm/s)    (mm/s)    (mm/s)\r\n 58120 86382. E01      -2.9     -51.0      35.2       3.2       2.7       3.7\r\n 58121 86382. E01     -16.1       3.6     -10.7      -0.4       3.6      -4.6\r\n 58122 86382. E01      -5.2     -12.6      -5.9       4.7       1.2      -1.1\r\n 58123 86382. E01     -64.1     -32.1      19.7       1.5      10.7       5.3\r\n```\r\nCode to visualise the data\r\n\r\n```python\r\nfrom datetime import datetime\r\n\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\nfrom astropy.time import Time\r\nfrom scipy import stats\r\nimport pandas as pd\r\n\r\nfilename = 'sp3_2018X.daybound'\r\n\r\ndataDt = [('MJD', np.int), ('sec', np.float), ('Const', '<U1'), ('RN', np.int), ('dRadial', np.float), ('dAlong', np.float), ('dCross', np.float)]\r\n \r\ndataInput = np.genfromtxt(filename, skip_header=2, delimiter=[6, 8, 1, 2, 10, 10, 10], dtype=dataDt)\r\nt1 = Time(dataInput['MJD'], scale='utc', format='mjd').datetime\r\n\r\ndfInput = pd.DataFrame(data=dataInput)\r\ndfInput = dfInput.assign(Time=t1)\r\ndfInput = dfInput.drop(['MJD', 'sec'], axis=1)\r\n\r\ndfInput.loc[:,'dRadial'] = dfInput.loc[:,'dRadial'].abs()\r\ndfInput.loc[:,'dAlong']  = dfInput.loc[:,'dAlong'].abs()\r\ndfInput.loc[:,'dCross']  = dfInput.loc[:,'dCross'].abs()\r\n\r\ndateSta = datetime(2018, 1, 1)\r\ndateEnd = datetime(2018, 7, 1)\r\ndfInput = dfInput[(dfInput['Time'] >= dateSta) & (dfInput['Time'] <= dateEnd)]\r\n\r\ndfInput.set_index(['Time', 'Const', 'RN'], inplace=True)\r\ndfInput.sort_index(level=['Time', 'Const', 'RN'], ascending=True, inplace=True)\r\n\r\ndfInput = dfInput[(np.abs(stats.zscore(dfInput)) < 100).all(axis=1)]\r\n\r\ntot3d = np.sqrt(dfInput['dRadial'] * dfInput['dRadial'] + dfInput['dCross'] * dfInput['dCross'] + dfInput['dAlong'] * dfInput['dAlong'])\r\ndfInput = dfInput.assign(dTotal=tot3d)\r\n\r\n\r\nc = 'E'\r\n\r\ndfSelect = dfInput.loc[(slice(None), c, slice(None)), :]\r\n\r\nsatList = dfSelect.loc[slice(None), :].reset_index().RN.unique()\r\nsatList = np.array([1])\r\n\r\nplt.ion()  \r\n  \r\nfor satIdx, s in enumerate(satList):\r\n\r\n    fig1, ax1 = plt.subplots()\r\n    figList.append(fig1)\r\n    axList.append(ax1)\r\n   \r\n    dfSelect.xs((c, s), level=['Const', 'RN']).dTotal.plot(ax=ax1 )\r\n    plt.ylabel('Orbit difference\\n at day boundary [mm]')\r\n    plt.xlabel('Date')\r\n    plt.xlim(dateSta, dateEnd)\r\n    plt.ylim([0, 3000])  \r\n\r\n    ax1.xaxis.set_major_locator(mpl.dates.MonthLocator())\r\n    ax1.xaxis.set_major_formatter(mpl.dates.DateFormatter('%b %y'))\r\n\r\n```\r\n\r\n#### Description\r\nHey guys,\r\n\r\nI am using the DataFrame.plot() function to visualize the file at the top with the code above. For many other examples this works as expected, but for this one I am getting the wrong year on the x-axis (49 instead of [20]18)\r\n\r\nI cannot reproduce the issue by using matplotlib directly, so I guess this is a pandas issue. Apologies, if I am mistaken.\r\n\r\nBest Regards\r\nVolker\r\n\r\n#### Output\r\n![figure_1-1](https://user-images.githubusercontent.com/32896877/42581982-4d676e44-852e-11e8-8fb8-2c7d165db17a.png)\r\n\r\n\r\n<details>\r\nINSTALLED VERSIONS\r\n------------------\r\ncommit: None\r\npython: 3.6.5.final.0\r\npython-bits: 64\r\nOS: Windows\r\nOS-release: 10\r\nmachine: AMD64\r\nprocessor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel\r\nbyteorder: little\r\nLC_ALL: None\r\nLANG: en\r\nLOCALE: None.None\r\n\r\npandas: 0.23.0\r\npytest: 3.5.1\r\npip: 10.0.1\r\nsetuptools: 39.1.0\r\nCython: 0.28.2\r\nnumpy: 1.14.3\r\nscipy: 1.1.0\r\npyarrow: None\r\nxarray: None\r\nIPython: 6.4.0\r\nsphinx: 1.7.4\r\npatsy: 0.5.0\r\ndateutil: 2.7.3\r\npytz: 2018.4\r\nblosc: None\r\nbottleneck: 1.2.1\r\ntables: 3.4.3\r\nnumexpr: 2.6.5\r\nfeather: None\r\nmatplotlib: 2.2.2\r\nopenpyxl: 2.5.3\r\nxlrd: 1.1.0\r\nxlwt: 1.3.0\r\nxlsxwriter: 1.0.4\r\nlxml: 4.2.1\r\nbs4: 4.6.0\r\nhtml5lib: 1.0.1\r\nsqlalchemy: 1.2.7\r\npymysql: None\r\npsycopg2: None\r\njinja2: 2.10\r\ns3fs: None\r\nfastparquet: None\r\npandas_gbq: None\r\npandas_datareader: None\r\n\r\n</details>\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/404518251","html_url":"https://github.com/pandas-dev/pandas/issues/21860#issuecomment-404518251","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/21860","id":404518251,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNDUxODI1MQ==","user":{"login":"VOMAY","id":32896877,"node_id":"MDQ6VXNlcjMyODk2ODc3","avatar_url":"https://avatars2.githubusercontent.com/u/32896877?v=4","gravatar_id":"","url":"https://api.github.com/users/VOMAY","html_url":"https://github.com/VOMAY","followers_url":"https://api.github.com/users/VOMAY/followers","following_url":"https://api.github.com/users/VOMAY/following{/other_user}","gists_url":"https://api.github.com/users/VOMAY/gists{/gist_id}","starred_url":"https://api.github.com/users/VOMAY/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VOMAY/subscriptions","organizations_url":"https://api.github.com/users/VOMAY/orgs","repos_url":"https://api.github.com/users/VOMAY/repos","events_url":"https://api.github.com/users/VOMAY/events{/privacy}","received_events_url":"https://api.github.com/users/VOMAY/received_events","type":"User","site_admin":false},"created_at":"2018-07-12T13:48:41Z","updated_at":"2018-07-12T13:48:41Z","author_association":"NONE","body":"@TomAugspurger \r\nI managed to shorten the code a bit, but the last line in crucial to highlight the error:\r\n![image](https://user-images.githubusercontent.com/32896877/42637186-bfea000a-85ea-11e8-8fd5-755c57903bab.png)\r\n\r\nDoing this i found out a new detail: If you remove the 58122 line from the input file, which will cause a gap in the sequence, the output will be correct:\r\n![image](https://user-images.githubusercontent.com/32896877/42637212-d287c648-85ea-11e8-86e0-b3b399e5c521.png)\r\n\r\n``` python\r\nfrom datetime import datetime\r\n\r\nimport numpy as np\r\nimport matplotlib.pyplot as plt\r\nimport matplotlib as mpl\r\nfrom astropy.time import Time\r\nfrom scipy import stats\r\nimport pandas as pd\r\n\r\nfilename = 'sp3_2018X.daybound'\r\n\r\ndataDt = [('MJD', np.int), ('sec', np.float), ('Const', '<U1'), ('RN', np.int), ('dRadial', np.float), ('dAlong', np.float), ('dCross', np.float)]\r\n \r\ndataInput = np.genfromtxt(filename, skip_header=2, delimiter=[6, 8, 1, 2, 10, 10, 10], dtype=dataDt)\r\nt1 = Time(dataInput['MJD'], scale='utc', format='mjd').datetime\r\n\r\ndfInput = pd.DataFrame(data=dataInput)\r\ndfInput = dfInput.assign(Time=t1)\r\ndfInput = dfInput.drop(['MJD', 'sec'], axis=1)\r\n\r\ndfInput.loc[:,'dRadial'] = dfInput.loc[:,'dRadial'].abs()\r\ndfInput.loc[:,'dAlong']  = dfInput.loc[:,'dAlong'].abs()\r\ndfInput.loc[:,'dCross']  = dfInput.loc[:,'dCross'].abs()\r\n\r\ndateSta = datetime(2018, 1, 1)\r\ndateEnd = datetime(2018, 7, 1)\r\ndfInput = dfInput[(dfInput['Time'] >= dateSta) & (dfInput['Time'] <= dateEnd)]\r\n\r\ndfInput.set_index(['Time', 'Const', 'RN'], inplace=True)\r\ndfInput.sort_index(level=['Time', 'Const', 'RN'], ascending=True, inplace=True)\r\n\r\ndfInput = dfInput[(np.abs(stats.zscore(dfInput)) < 100).all(axis=1)]\r\n\r\ndfSelect = dfInput.loc[(slice(None), 'E', slice(None)), :]\r\n\r\n\r\nfig1, ax1 = plt.subplots()\r\n\r\ndfSelect.xs(('E', 1), level=['Const', 'RN']).dRadial.plot(ax=ax1, xlim=(dateSta, dateEnd))\r\n\r\nax1.xaxis.set_major_formatter(mpl.dates.DateFormatter('%b %y'))\r\n``` "}}
{"actor":{"display_login":"VOMAY"}}