Inconsitent index for plot · Issue #26186 · pandas-dev/pandas (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@Jeanselme

Description

@Jeanselme

Code Sample

import pandas as pd import matplotlib.pyplot as plt

data = {"A":0, "B":3, "C":-4} df = pd.DataFrame.from_dict(data, orient = "index", columns = ["Value"]) ax = df.plot.barh()

df = df.sort_values("Value") * - 2 df.plot.barh(ax = ax, color = "red") plt.show()

Problem description

The second plot overwrites the first index even if it is not in the same order, producing incoherent figure where the ylabel does not match with the data displayed.
The current output (pandas 0.24.1) creates
current
instead of
correct

I don't know if this is related to the way pandas handles index or matplotlib.