I am looking for a way to include a (matplotlib) legend that describe the size of points in a scatter plot, as this could be related to another variable, like in this basic
I almost like mjp's answer, but it doesn't quite work because plt.plot's 'markersize' argument doesn't mean the same thing as plt.scatter's 's' argument. Your sizes will be wrong using plt.plot.
Instead use:
marker1 = plt.scatter([],[], s=a2.min())
marker2 = plt.scatter([],[], s=a2.max())
legend_markers = [marker1, marker2]
labels = [
str(round(a2.min(),2)),
str(round(a2.max(),2))
]
fig.legend(handles=legend_markers, labels=labels, loc='upper_right',
scatterpoints=1)