Logo Questions Linux Laravel Mysql Ubuntu Git Menu

matplolib doesn't show legend starting with underscore _

I have the following code in python :

import matplotlib.pyplot as plt

And when running it, the following warning appears :

/usr/lib/pymodules/python2.7/matplotlib/axes.py:4486: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labeled objects found. "

and no legend shows up.

It appears, after trying to remove the '_' at the beginning of the label that the problem comes from here.

Does anybody know why it is so ? Is it a known voluntary/logical feature, an inconvenience or a bug ? Is it reported anywhere, since i couldn't find anything about this on http://matplotlib.org/users/legend_guide.html ? Is it specific to the label of the legend or it occurs as well with some other labels (title, xylabels maybe ?)

Thank you very much for your help

like image 291
wohlrajh Avatar asked Mar 17 '23 23:03


1 Answers

It is documented in the documentation for legend, which is linked from the page you linked to:

Specific lines can be excluded from the automatic legend element selection by defining a label starting with an underscore.

like image 195
BrenBarn Avatar answered Mar 21 '23 08:03