I am always bothered when I make a bar plot with pandas and I want to change the names of the labels in the legend. Consider for instance the output of this code:
import pandas as pd
from matplotlib.pyplot import *
df = pd.DataFrame({'A':26, 'B':20}, index=['N'])
df.plot(kind='bar')
Now, if I want to change the name in the legend, I would usually try to do:
legend(['AAA', 'BBB'])
But I end up with this:
In fact, the first dashed line seems to correspond to an additional patch.
So I wonder if there is a simple trick here to change the labels, or do I need to plot each of the columns independently with matplotlib and set the labels myself. Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…