prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [BUG] plot_series inconsistent date/time index 
  **Describe the bug**
  <!--
  A clear and concise description of what the bug is.
  -->
  
  **To Reproduce**
  
  ```python
  y = load_airline()
  y = y[:48]
  fh=np.arange(1, 13)
  
  y_train, y_test = temporal_train_test_split(y, test_size=len(fh))
  plot_series(y_train, y_test, labels=["y_train", "y_test"]);
  print(y.shape, y_train.shape[0], y_test.shape[0])
  print(y.index)
  ```
  
  > (48,) 36 12
  > PeriodIndex(['1949-01', '1949-02', '1949-03', '1949-04', '1949-05', '1949-06',
  >              '1949-07', '1949-08', '1949-09', '1949-10', '1949-11', '1949-12',
  >              '1950-01', '1950-02', '1950-03', '1950-04', '1950-05', '1950-06',
  >              '1950-07', '1950-08', '1950-09', '1950-10', '1950-11', '1950-12',
  >              '1951-01', '1951-02', '1951-03', '1951-04', '1951-05', '1951-06',
  >              '1951-07', '1951-08', '1951-09', '1951-10', '1951-11', '1951-12',
  >              '1952-01', '1952-02', '1952-03', '1952-04', '1952-05', '1952-06',
  >              '1952-07', '1952-08', '1952-09', '1952-10', '1952-11', '1952-12'],
  >             dtype='period[M]', name='Period', freq='M')
  > 
  
  **Expected behavior**
  The X-axis should go till end of 1952. The X-axis on the plot does not reflect the indices correctly. It should go till 1952, but shows values only till 1949
  
  ![image](https://user-images.githubusercontent.com/33585645/100865855-800ef980-345d-11eb-9980-476454e8de68.png)
  
  **Versions**
  System:
      python: 3.6.12 |Anaconda, Inc.| (default, Sep  9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]
  executable: C:\Users\xxxx\AppData\Local\Continuum\anaconda3\envs\sktime\python.exe
     machine: Windows-10-10.0.18362-SP0
  
  Python dependencies:
            pip: 20.3
     setuptools: 49.6.0
        sklearn: 0.23.2
          numpy: 1.19.2
          scipy: 1.5.2
         Cython: 0.29.17
         pandas: 1.1.3
     matplotlib: 3.3.2
         joblib: 0.17.0
          numba: None
       pmdarima: 1.7.1
        tsfresh: None
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sktime/utils/plotting/__init__.py`
  Content:
  ```
  1 #!/usr/bin/env python3 -u
  2 # -*- coding: utf-8 -*-
  3 # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
  4 
  5 __all__ = ["plot_series"]
  6 __author__ = ["Markus Löning"]
  7 
  8 import warnings
  9 
  10 import numpy as np
  11 
  12 from sktime.utils.check_imports import _check_soft_dependencies
  13 from sktime.utils.validation.forecasting import check_y
  14 
  15 
  16 def plot_series(*series, labels=None):
  17     """Plot one or more time series
  18 
  19     Parameters
  20     ----------
  21     series : pd.Series
  22         One or more time series
  23     labels : list, optional (default=None)
  24         Names of series, will be displayed in figure legend
  25 
  26     Returns
  27     -------
  28     fig : plt.Figure
  29     ax : plt.Axis
  30     """
  31     _check_soft_dependencies("matplotlib", "seaborn")
  32     import matplotlib.pyplot as plt
  33     import seaborn as sns
  34 
  35     n_series = len(series)
  36     if labels is not None:
  37         if n_series != len(labels):
  38             raise ValueError(
  39                 "There must be one label for each time series, "
  40                 "but found inconsistent numbers of series and "
  41                 "labels."
  42             )
  43         legend = True
  44     else:
  45         labels = ["" for _ in range(n_series)]
  46         legend = False
  47 
  48     for y in series:
  49         check_y(y)
  50 
  51     # create combined index
  52     index = series[0].index
  53     for y in series[1:]:
  54         # check types, note that isinstance() does not work here because index
  55         # types inherit from each other, hence we check for type equality
  56         if not type(index) is type(y.index):  # noqa
  57             raise TypeError("Found series with different index types.")
  58         index = index.union(y.index)
  59 
  60     # generate integer x-values
  61     xs = [np.argwhere(index.isin(y.index)).ravel() for y in series]
  62 
  63     # create figure
  64     fig, ax = plt.subplots(1, figsize=plt.figaspect(0.25))
  65     colors = sns.color_palette("colorblind", n_colors=n_series)
  66 
  67     # plot series
  68     for x, y, color, label in zip(xs, series, colors, labels):
  69 
  70         # scatter if little data is available or index is not complete
  71         if len(x) <= 3 or not np.array_equal(np.arange(x[0], x[-1] + 1), x):
  72             plot_func = sns.scatterplot
  73         else:
  74             plot_func = sns.lineplot
  75 
  76         plot_func(x=x, y=y, ax=ax, marker="o", label=label, color=color)
  77 
  78     # set combined index as xticklabels, suppress matplotlib warning
  79     with warnings.catch_warnings():
  80         warnings.filterwarnings("ignore")
  81         ax.set(xticklabels=index)
  82 
  83     if legend:
  84         ax.legend()
  85 
  86     return fig, ax
  87
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/sktime/utils/plotting/__init__.py b/sktime/utils/plotting/__init__.py
  --- a/sktime/utils/plotting/__init__.py
  +++ b/sktime/utils/plotting/__init__.py
  @@ -5,8 +5,6 @@
   __all__ = ["plot_series"]
   __author__ = ["Markus Löning"]
   
  -import warnings
  -
   import numpy as np
   
   from sktime.utils.check_imports import _check_soft_dependencies
  @@ -30,6 +28,8 @@
       """
       _check_soft_dependencies("matplotlib", "seaborn")
       import matplotlib.pyplot as plt
  +    from matplotlib.ticker import FuncFormatter, MaxNLocator
  +    from matplotlib.cbook import flatten
       import seaborn as sns
   
       n_series = len(series)
  @@ -75,10 +75,19 @@
   
           plot_func(x=x, y=y, ax=ax, marker="o", label=label, color=color)
   
  -    # set combined index as xticklabels, suppress matplotlib warning
  -    with warnings.catch_warnings():
  -        warnings.filterwarnings("ignore")
  -        ax.set(xticklabels=index)
  +    # combine data points for all series
  +    xs_flat = list(flatten(xs))
  +
  +    # set x label of data point to the matching index
  +    def format_fn(tick_val, tick_pos):
  +        if int(tick_val) in xs_flat:
  +            return index[int(tick_val)]
  +        else:
  +            return ""
  +
  +    # dynamically set x label ticks and spacing from index labels
  +    ax.xaxis.set_major_formatter(FuncFormatter(format_fn))
  +    ax.xaxis.set_major_locator(MaxNLocator(integer=True))
   
       if legend:
           ax.legend()
  
verification_info: {"golden_diff": "diff --git a/sktime/utils/plotting/__init__.py b/sktime/utils/plotting/__init__.py\n--- a/sktime/utils/plotting/__init__.py\n+++ b/sktime/utils/plotting/__init__.py\n@@ -5,8 +5,6 @@\n __all__ = [\"plot_series\"]\n __author__ = [\"Markus L\u00f6ning\"]\n \n-import warnings\n-\n import numpy as np\n \n from sktime.utils.check_imports import _check_soft_dependencies\n@@ -30,6 +28,8 @@\n     \"\"\"\n     _check_soft_dependencies(\"matplotlib\", \"seaborn\")\n     import matplotlib.pyplot as plt\n+    from matplotlib.ticker import FuncFormatter, MaxNLocator\n+    from matplotlib.cbook import flatten\n     import seaborn as sns\n \n     n_series = len(series)\n@@ -75,10 +75,19 @@\n \n         plot_func(x=x, y=y, ax=ax, marker=\"o\", label=label, color=color)\n \n-    # set combined index as xticklabels, suppress matplotlib warning\n-    with warnings.catch_warnings():\n-        warnings.filterwarnings(\"ignore\")\n-        ax.set(xticklabels=index)\n+    # combine data points for all series\n+    xs_flat = list(flatten(xs))\n+\n+    # set x label of data point to the matching index\n+    def format_fn(tick_val, tick_pos):\n+        if int(tick_val) in xs_flat:\n+            return index[int(tick_val)]\n+        else:\n+            return \"\"\n+\n+    # dynamically set x label ticks and spacing from index labels\n+    ax.xaxis.set_major_formatter(FuncFormatter(format_fn))\n+    ax.xaxis.set_major_locator(MaxNLocator(integer=True))\n \n     if legend:\n         ax.legend()\n", "issue": "[BUG] plot_series inconsistent date/time index \n**Describe the bug**\r\n<!--\r\nA clear and concise description of what the bug is.\r\n-->\r\n\r\n**To Reproduce**\r\n\r\n```python\r\ny = load_airline()\r\ny = y[:48]\r\nfh=np.arange(1, 13)\r\n\r\ny_train, y_test = temporal_train_test_split(y, test_size=len(fh))\r\nplot_series(y_train, y_test, labels=[\"y_train\", \"y_test\"]);\r\nprint(y.shape, y_train.shape[0], y_test.shape[0])\r\nprint(y.index)\r\n```\r\n\r\n> (48,) 36 12\r\n> PeriodIndex(['1949-01', '1949-02', '1949-03', '1949-04', '1949-05', '1949-06',\r\n>              '1949-07', '1949-08', '1949-09', '1949-10', '1949-11', '1949-12',\r\n>              '1950-01', '1950-02', '1950-03', '1950-04', '1950-05', '1950-06',\r\n>              '1950-07', '1950-08', '1950-09', '1950-10', '1950-11', '1950-12',\r\n>              '1951-01', '1951-02', '1951-03', '1951-04', '1951-05', '1951-06',\r\n>              '1951-07', '1951-08', '1951-09', '1951-10', '1951-11', '1951-12',\r\n>              '1952-01', '1952-02', '1952-03', '1952-04', '1952-05', '1952-06',\r\n>              '1952-07', '1952-08', '1952-09', '1952-10', '1952-11', '1952-12'],\r\n>             dtype='period[M]', name='Period', freq='M')\r\n> \r\n\r\n**Expected behavior**\r\nThe X-axis should go till end of 1952. The X-axis on the plot does not reflect the indices correctly. It should go till 1952, but shows values only till 1949\r\n\r\n![image](https://user-images.githubusercontent.com/33585645/100865855-800ef980-345d-11eb-9980-476454e8de68.png)\r\n\r\n**Versions**\r\nSystem:\r\n    python: 3.6.12 |Anaconda, Inc.| (default, Sep  9 2020, 00:29:25) [MSC v.1916 64 bit (AMD64)]\r\nexecutable: C:\\Users\\xxxx\\AppData\\Local\\Continuum\\anaconda3\\envs\\sktime\\python.exe\r\n   machine: Windows-10-10.0.18362-SP0\r\n\r\nPython dependencies:\r\n          pip: 20.3\r\n   setuptools: 49.6.0\r\n      sklearn: 0.23.2\r\n        numpy: 1.19.2\r\n        scipy: 1.5.2\r\n       Cython: 0.29.17\r\n       pandas: 1.1.3\r\n   matplotlib: 3.3.2\r\n       joblib: 0.17.0\r\n        numba: None\r\n     pmdarima: 1.7.1\r\n      tsfresh: None\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python3 -u\n# -*- coding: utf-8 -*-\n# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\n__all__ = [\"plot_series\"]\n__author__ = [\"Markus L\u00f6ning\"]\n\nimport warnings\n\nimport numpy as np\n\nfrom sktime.utils.check_imports import _check_soft_dependencies\nfrom sktime.utils.validation.forecasting import check_y\n\n\ndef plot_series(*series, labels=None):\n    \"\"\"Plot one or more time series\n\n    Parameters\n    ----------\n    series : pd.Series\n        One or more time series\n    labels : list, optional (default=None)\n        Names of series, will be displayed in figure legend\n\n    Returns\n    -------\n    fig : plt.Figure\n    ax : plt.Axis\n    \"\"\"\n    _check_soft_dependencies(\"matplotlib\", \"seaborn\")\n    import matplotlib.pyplot as plt\n    import seaborn as sns\n\n    n_series = len(series)\n    if labels is not None:\n        if n_series != len(labels):\n            raise ValueError(\n                \"There must be one label for each time series, \"\n                \"but found inconsistent numbers of series and \"\n                \"labels.\"\n            )\n        legend = True\n    else:\n        labels = [\"\" for _ in range(n_series)]\n        legend = False\n\n    for y in series:\n        check_y(y)\n\n    # create combined index\n    index = series[0].index\n    for y in series[1:]:\n        # check types, note that isinstance() does not work here because index\n        # types inherit from each other, hence we check for type equality\n        if not type(index) is type(y.index):  # noqa\n            raise TypeError(\"Found series with different index types.\")\n        index = index.union(y.index)\n\n    # generate integer x-values\n    xs = [np.argwhere(index.isin(y.index)).ravel() for y in series]\n\n    # create figure\n    fig, ax = plt.subplots(1, figsize=plt.figaspect(0.25))\n    colors = sns.color_palette(\"colorblind\", n_colors=n_series)\n\n    # plot series\n    for x, y, color, label in zip(xs, series, colors, labels):\n\n        # scatter if little data is available or index is not complete\n        if len(x) <= 3 or not np.array_equal(np.arange(x[0], x[-1] + 1), x):\n            plot_func = sns.scatterplot\n        else:\n            plot_func = sns.lineplot\n\n        plot_func(x=x, y=y, ax=ax, marker=\"o\", label=label, color=color)\n\n    # set combined index as xticklabels, suppress matplotlib warning\n    with warnings.catch_warnings():\n        warnings.filterwarnings(\"ignore\")\n        ax.set(xticklabels=index)\n\n    if legend:\n        ax.legend()\n\n    return fig, ax\n", "path": "sktime/utils/plotting/__init__.py"}], "after_files": [{"content": "#!/usr/bin/env python3 -u\n# -*- coding: utf-8 -*-\n# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\n__all__ = [\"plot_series\"]\n__author__ = [\"Markus L\u00f6ning\"]\n\nimport numpy as np\n\nfrom sktime.utils.check_imports import _check_soft_dependencies\nfrom sktime.utils.validation.forecasting import check_y\n\n\ndef plot_series(*series, labels=None):\n    \"\"\"Plot one or more time series\n\n    Parameters\n    ----------\n    series : pd.Series\n        One or more time series\n    labels : list, optional (default=None)\n        Names of series, will be displayed in figure legend\n\n    Returns\n    -------\n    fig : plt.Figure\n    ax : plt.Axis\n    \"\"\"\n    _check_soft_dependencies(\"matplotlib\", \"seaborn\")\n    import matplotlib.pyplot as plt\n    from matplotlib.ticker import FuncFormatter, MaxNLocator\n    from matplotlib.cbook import flatten\n    import seaborn as sns\n\n    n_series = len(series)\n    if labels is not None:\n        if n_series != len(labels):\n            raise ValueError(\n                \"There must be one label for each time series, \"\n                \"but found inconsistent numbers of series and \"\n                \"labels.\"\n            )\n        legend = True\n    else:\n        labels = [\"\" for _ in range(n_series)]\n        legend = False\n\n    for y in series:\n        check_y(y)\n\n    # create combined index\n    index = series[0].index\n    for y in series[1:]:\n        # check types, note that isinstance() does not work here because index\n        # types inherit from each other, hence we check for type equality\n        if not type(index) is type(y.index):  # noqa\n            raise TypeError(\"Found series with different index types.\")\n        index = index.union(y.index)\n\n    # generate integer x-values\n    xs = [np.argwhere(index.isin(y.index)).ravel() for y in series]\n\n    # create figure\n    fig, ax = plt.subplots(1, figsize=plt.figaspect(0.25))\n    colors = sns.color_palette(\"colorblind\", n_colors=n_series)\n\n    # plot series\n    for x, y, color, label in zip(xs, series, colors, labels):\n\n        # scatter if little data is available or index is not complete\n        if len(x) <= 3 or not np.array_equal(np.arange(x[0], x[-1] + 1), x):\n            plot_func = sns.scatterplot\n        else:\n            plot_func = sns.lineplot\n\n        plot_func(x=x, y=y, ax=ax, marker=\"o\", label=label, color=color)\n\n    # combine data points for all series\n    xs_flat = list(flatten(xs))\n\n    # set x label of data point to the matching index\n    def format_fn(tick_val, tick_pos):\n        if int(tick_val) in xs_flat:\n            return index[int(tick_val)]\n        else:\n            return \"\"\n\n    # dynamically set x label ticks and spacing from index labels\n    ax.xaxis.set_major_formatter(FuncFormatter(format_fn))\n    ax.xaxis.set_major_locator(MaxNLocator(integer=True))\n\n    if legend:\n        ax.legend()\n\n    return fig, ax\n", "path": "sktime/utils/plotting/__init__.py"}]}