You're right, the 4-tuple in plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3)
is set as (x0, y0, width, height)
where (x0,y0)
are the lower left corner coordinates of the bounding box.
While those parameters set the bounding box for the legend, the legend's actual vertical size is shrunk to the size that is needed to put the elements in. Further its position is determined only in conjunction with the loc
parameter. The loc parameter sets the alignment of the legend inside the bounding box, such that for some cases, no difference will by seen when changing the height
, compare e.g. plot (2) and (4).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…