Removing the frame from legends in matplotlib

One of the features of the legends from matplotlib that can be distracting is the black borders around every legend. To remove them, or to change other properties of the frame, you can use the get_frame() function and adjust the properties of the legend. For example:

leg = legend()
leg.get_frame().set_alpha(0) # this will make the box totally transparent
leg.get_frame().set_edgecolor('white') # this will make the edges of the border white to match the background instead

More info about changes to legends can be found here: