Skip to content
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

label keyword is not interpreted proporly in errorbar() for pandas.DataFrame-like objects #5565

Closed
monodera opened this issue Nov 25, 2015 · 1 comment

Comments

@monodera
Copy link

I encountered an issue of the legend in matplotlib.pyplot.errorbar when I plot a pandas' DataFrame object. A minimum example based on the release note of v1.5 is the following.

import pandas
import numpy as np
import matplotlib.pyplot as plt

df = pandas.DataFrame({"var1":[1,2,3,4,5,6], "var2":[1,2,3,4,5,6]})

Here is the same as one in the release note, but with a legend.

plt.plot(df["var1"], df["var2"], label='test')
plt.legend()

The output is the following.

test_pandas_plot

The following code makes the issue.

plt.errorbar(df["var1"], df["var2"], label='test')
plt.legend()

test_pandas_err

As you can see, the 'var2' key is not overridden by the label='test' and there are two lines instead of one in the legend.

A quick workaround is to convert the y values to numpy array with np.array(df["var2"]) when plotting.

I'm using Python 2.7.8 installed via homebrew on OS X 10.10.5, matplotlib 1.5.0, and pandas 0.17.0.

@tacaswell
Copy link
Member

I think this is a duplicate of #5393

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants