Reputation: 1173
I try to place the legend on the plot, but matplotlib place at the location in a uncomprehending way.Can any one tell me the reason?
The image content show details.
Upvotes: 0
Views: 738
Reputation: 707
This behavior is intended. In the documentation it says that you can use loc
and bbox_to_anchor
together. In this case, loc
specifies which corner of the legend is located at bbox_to_anchor
:
A 2-tuple (x, y) places the corner of the legend specified by loc at x, y. For example, to put the legend's upper right-hand corner in the center of the axes (or figure) the following keywords can be used:
loc='upper right', bbox_to_anchor=(0.5, 0.5)
However, if you only use loc
the legend is placed in the way you thought it should be placed.
Upvotes: 1