Changing the handlelength globally affects the width of other markers in the legend. Therefore, this solution will be incompatible with, for example, a combination of points and lines. Instead, you can simply add a square dot marker to the legend using Line2D . You just need to set the associated string to zero width:
rect1 = mlines.Line2D([], [], marker="s", markersize=30, linewidth=0, color="r") rect2 = mlines.Line2D([], [], marker="s", markersize=30, linewidth=0, color="y") ax.legend((rect1, rect2), ('Men', 'Women'))
Cyrus
source share