Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas plot() without a legend

Using the pandas library in python and using

.plot() 

on a dataframe, how do I display the plot without a legend?

like image 681
Bilal Syed Hussain Avatar asked Jan 01 '14 04:01

Bilal Syed Hussain


People also ask

How do you get rid of the legend in pandas plot?

Using plt. gca(). legend_. remove() after the call to parallel_coordinates successfully turned off the legend.

How do you plot without legend?

If you want to plot a Pandas dataframe and want to remove the legend, add legend=None as parameter to the plot command. Show activity on this post.

How do I get rid of Matplotlib legend legends?

We could use remove() and set_visible() methods of the legend object to remove legend from a figure in Matplotlib. We can also remove legend from a figure in Matplotlib by setting the label to _nolegend_ in plot() method, axes. legend to None and figure.


1 Answers

There is a parameter in the function corresponding to legend; by default it is True

df.plot(legend=False) 

Following is the definition of the .plot() method

Definition: df.plot(frame=None, x=None, y=None, subplots=False, sharex=True, sharey=False, use_index=True, figsize=None, grid=None, legend=True, rot=None, ax=None, style=None, title=None, xlim=None, ylim=None, logx=False, logy=False, xticks=None, yticks=None, kind='line', sort_columns=False, fontsize=None, secondary_y=False, **kwds)

like image 84
Nipun Batra Avatar answered Sep 23 '22 02:09

Nipun Batra