Skip to content

Commit a0cd359

Browse files
committed
adding a test for bar plot with intervalrange xaxis
1 parent 264da3b commit a0cd359

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/plotting/test_misc.py

+14
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Index,
1111
Series,
1212
Timestamp,
13+
interval_range,
1314
)
1415
import pandas._testing as tm
1516
from pandas.tests.plotting.common import (
@@ -582,3 +583,16 @@ def test_plot_bar_axis_units_timestamp_conversion(self):
582583
_check_plot_works(df.plot)
583584
s = Series({"A": 1.0})
584585
_check_plot_works(s.plot.bar)
586+
587+
def test_bar_plt_xaxis_intervalrange(self):
588+
# GH 38969
589+
# Ensure IntervalIndex x-axis produces a bar plot as expected
590+
from matplotlib.text import Text
591+
592+
expected = [Text(0, 0, "([0, 1],)"), Text(1, 0, "([1, 2],)")]
593+
s = Series(
594+
[1, 2],
595+
index=[interval_range(0, 2)],
596+
)
597+
_check_plot_works(s.plot.bar)
598+
assert s.plot.bar().get_xticklabels() == expected

0 commit comments

Comments
 (0)