In this article, we will learn how to Remove the legend border in Matplotlib. Let’s discuss some concepts :
- A legend is an area describing the elements of the graph. In the matplotlib library, there’s a function called legend() which is used to Place a legend on the axes.
- Import Library (Matplotlib)
- Import / create data.
- Plot a chart.
- Add legend.
- Remove legend border.
Example: Here is an example with legends.
Method 1: (Using frameon = False)
Method 2: (Using legend.get_frame().set_alpha(0))
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course