In Matplotlib, I'm trying to make a legend with colored "markers" like this one :
this one has been made using the scatter
function, but is not adapted to my plot. I'd like to produce a legend "from scratch", without associated data.
The color is important, and therefore should be an attribute of each marker.
I've tried
import matplotlib.markers as mmark
list_mak = [mmark.MarkerStyle('.'),mmark.MarkerStyle(','),mmark.MarkerStyle('o')]
list_lab = ['Marker 1','Marker 2','Marker 3']
plt.legend(list_mak,list_lab)
But :
The
MarkerStyle
class doesn't support color informationI get the warning :
UserWarning: Legend does not support <matplotlib.markers.MarkerStyle object at 0x7fca640c44d0> instances. A proxy artist may be used instead.
But how can I define a proxy artist based on a marker ?
line2D
object. There's no reason why you can't do the same (with just a marker, no line) for each of your markers.