Skip to content

Commit

Permalink
TST: GH38947 creating function to test bar plot index (#46451)
Browse files Browse the repository at this point in the history
* TST: GH38947 creating function to test bar plot index

* TST: GH38947 removing try/except since assert will raise appropriately
  • Loading branch information
Daquisu authored Apr 24, 2022
1 parent edec493 commit 2e56a83
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from pandas import (
DataFrame,
Index,
Series,
Timestamp,
)
Expand Down Expand Up @@ -441,6 +442,25 @@ def test_dictionary_color(self):
colors = [rect.get_color() for rect in ax.get_lines()[0:2]]
assert all(color == expected[index] for index, color in enumerate(colors))

def test_bar_plot(self):
# GH38947
# Test bar plot with string and int index
from matplotlib.text import Text

expected = [Text(0, 0, "0"), Text(1, 0, "Total")]

df = DataFrame(
{
"a": [1, 2],
},
index=Index([0, "Total"]),
)
plot_bar = df.plot.bar()
assert all(
(a.get_text() == b.get_text())
for a, b in zip(plot_bar.get_xticklabels(), expected)
)

def test_has_externally_shared_axis_x_axis(self):
# GH33819
# Test _has_externally_shared_axis() works for x-axis
Expand Down

0 comments on commit 2e56a83

Please sign in to comment.