Quantcast
Channel: How to specify legend position in graph coordinates - Stack Overflow
Viewing all articles
Browse latest Browse all 12

Answer by BeastOfCaerbannog for How to specify legend position in matplotlib in graph coordinates

$
0
0

According to the matplotlib legend documentation:

The location can also be a 2-tuple giving the coordinates of the lower-left corner of the legend in axes coordinates (in which case bbox_to_anchor will be ignored).

Thus, one could use:

plt.legend(loc=(x, y))

to set the legend's lower left corner to the specified (x, y) position.

Note that the x and y coordinates here are relative, meaning that x=0 is the left most point in the plot and x=1 is the rightmost point in the plot. Similarly for y = 0 and y = 1 along the height of the plot.


Viewing all articles
Browse latest Browse all 12

Trending Articles