How to exclude the elements from the legend in python?



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')


@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!