图例元素的字符串标签。 注:本文由纯净天空筛选整理自skytowner.com大神的英文原创作品matplotlib.collections.PathCollection.legend_elements。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
legend_elements()) # this will show legend with 1,2,3, 4, 5,6,7,8,10 import matplotlib.pyplot as plt n = 10 sc = plt.scatter([1]*n, list(range(n)), c=[1,2, 3, 4, 5,6,7,8,9,11]) plt.legend(*sc.legend_elements()) # this will show legend with 1,2,3,4,5,6...