How to exclude the elements from the legend in python?

ipython

#1

I have created a plot in Ipython notebook in which there is one legend . I want to know how to remove some element from the legend in Ipython notebook.

fig = plt.figure(); ax = fig.add_subplot(1, 1, 1)
ax.plot(randn(1000).cumsum(), 'k', label='one')
ax.plot(randn(1000).cumsum(), 'k--', label='two')
ax.plot(randn(1000).cumsum(), 'k.', label='three')
ax.legend(loc='best')


#2

@sid100158- To exclude one or more elements from the legend, pass no label or label=‘nolegend’.

for your question you can use this command to exclude one or more elements from the legend.

ax.plot(randn(1000).cumsum(), 'k.', label='_nolegend_')

Hope this helps!

Regards,
Hinduja