I have a subplot with an external, horizontal legend (figure legend), and super title (suptitle
). I would like to align them on the bottom of the text, vertically. I set the vertical position of the title with fig.suptitle('title', ha='left', y=placement)
. When I try to set the legend's location with fig.legend(handles, labels, loc=(0.65, placement))
, It is not aligned. I suspect this is an issue with the point the objects are aligned on and that the legend has a border... so I changed the padding of the legend to 0, but still have to tweak it.
How could I explicitly set the anchor point, or node, of the suptitle and legend?
EDIT
Image attached below. I believe I have solved the problem with setting the suptitle
parameter va='bottom
, and legend
parameters borderpad=0.0, borderaxespad=0
. Now, if I do have a border, how would I do this? I would also like to know how to explicitly set the anchor point of the legend.
SOLUTION
When you set the bbox_to_anchor
parameter in the legend, it basically changed where the legend is clipped to. If the bbox
has no height or width (2-tuple), it is a point. The loc
parameter is then the point on the legend frame that is anchored to the bbox
. When loc
is used on it's on, the bbox
is determined by MPL.
Let's say I wanted the title on the left, legend on the right (with no box), and horizontally aligned at the bottom. Mmy solution would look like:
fig.suptitle('title', ha='left', va='bottom', y=placement, x=0.02)
fig.legend(handles, labels,
loc='lower right',
bbox_to_anchor=(0.98, placement),
borderpad=0.0,
borderaxespad=0,
ncol=3,
)