chevron_left
Legend Cookbook
thumb_up
0
thumb_down
0
chat_bubble_outline
0
auto_stories new
settings
Removing the legend in Matplotlib
Programming
chevron_rightPython
chevron_rightMatplotlib
chevron_rightCookbooks
chevron_rightLegend Cookbook
schedule Jul 1, 2022
Last updated local_offer Python●Matplotlib
Tags tocTable of Contents
expand_more To remove the legend in Matplotlib:
plt.plot([1,2,3])plt.plot([3,2,1])
# Add the legendplt.legend(["my_blue", "my_orange"])
# Remove the legendplt.gca().get_legend().remove()
plt.show()
This gives you the following:

Notice how we don't have the legend since we deleted the one we added.
Join our newsletter for updates on new DS/ML comprehensive guides (spam-free)
Published by Isshin Inada
Edited by 0 others
Did you find this page useful?
thumb_up
thumb_down
Ask a question or leave a feedback...
thumb_up
0
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!