Skip to content

REGR: Barplot broken on Index(dtype='object') #44033

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import numpy as np
import pytest
from matplotlib.text import Text

import pandas.util._test_decorators as td

from pandas import (
DataFrame,
Series,
Series, Index,
)
import pandas._testing as tm
from pandas.tests.plotting.common import (
Expand Down Expand Up @@ -450,6 +451,26 @@ 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):
# issue-38947
# Test bar plot with string index

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

df = DataFrame(
{
'a': [1, 2],
},
index=Index([0, 'Total'])
)

try:
plot_bar = df.plot.bar()
assert all([(a.get_text() == b.get_text())
for a, b in zip(plot_bar.get_xticklabels(), expected)])
except TypeError as e:
assert False

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