Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

get legend lables and handles from plot in matplotlib

import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_axes([0.15,0.2,0.7,0.7])
ax.plot([0,1],[0,1],lable = "Test)
#Get handles and labels         
handles, labels = ax.get_legend_handles_labels()
#Handles can be used in a user defined legend!         
 
PREVIOUS NEXT
Tagged: #legend #lables #handles #plot #matplotlib
ADD COMMENT
Topic
Name
8+7 =