Subheadings for categories within matplotlib custom legend
问题 I have a a figure that looks like this: I\'d like to make a legend that looks like this: How can I do that? UPDATE: Note that this legend has a frame with an edgecolor: a valid answer will include this. The legend should also be embedded in the axes. The legend I want might not be achievable using ax.legend() . A great answer would be one which shows how to build my desired legend (exactly as shown) manually with patches and texts, or whatever matplotlib methods that make sense. 回答1: Separate