Skip to content

Commit 97d0440

Browse files
committed
Handle line and box on the same plot
1 parent 3caf8e6 commit 97d0440

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

pandas/plotting/_matplotlib/core.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959

6060
from pandas.io.formats.printing import pprint_thing
6161
from pandas.plotting._matplotlib import tools
62-
from pandas.plotting._matplotlib.converter import register_pandas_matplotlib_converters
62+
from pandas.plotting._matplotlib.converter import (
63+
PeriodConverter,
64+
register_pandas_matplotlib_converters,
65+
)
6366
from pandas.plotting._matplotlib.groupby import reconstruct_data_with_by
6467
from pandas.plotting._matplotlib.misc import unpack_single_str_list
6568
from pandas.plotting._matplotlib.style import get_standard_colors
@@ -1867,11 +1870,13 @@ def __init__(
18671870

18681871
MPLPlot.__init__(self, data, **kwargs)
18691872

1870-
self.tick_pos = (
1871-
np.array(self.ax.xaxis.convert_units(self._get_xticks()))
1872-
if isinstance(data.index, ABCPeriodIndex)
1873-
else np.arange(len(data))
1874-
)
1873+
if isinstance(data.index, ABCPeriodIndex):
1874+
self.ax.freq = data.index.freq
1875+
self.tick_pos = np.array(
1876+
PeriodConverter.convert(data.index._mpl_repr(), None, self.ax)
1877+
)
1878+
else:
1879+
self.tick_pos = np.arange(len(data))
18751880

18761881
@cache_readonly
18771882
def ax_pos(self) -> np.ndarray:

0 commit comments

Comments
 (0)