I tried using label=None
in the plot command, in which case matplotlib
chose the key of the data as a label. I find this behavior unintuitive and expected to have full control over the label when I set it explicitly.
How can I disable the label of a plot involving data from a pandas
dataframe?
Here is a small example, which shows the behavior:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({'x': [0, 1], 'y': [0, 1]})
plt.plot(df['x'], df['y'], label=None)
plt.legend(loc='best')
This results in the following plot:
In case it matters, I'm currently using matplotlib version 1.5.1 and pandas version 0.18.0 in the following python installed from macports: Python 2.7.11 (default, Mar 1 2016, 18:40:10) [GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
If you pass an empty string then it results in this plot:
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame({'x': [0, 1], 'y': [0, 1]})
plt.plot(df['x'], df['y'], label='')
plt.legend(loc='best')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With