Skip to content

legend(bbox_transform) don't work with tight layout in 2.2.x #11041

Closed
@fredrik-1

Description

@fredrik-1

The following code worked as expected in matplotlib 2.1.x but doesn't work in matplotlib 2.2.x

fig=plt.figure(1)
fig.clf()
ax=[fig.add_subplot(2,2,i+1) for i in range(4)]
for j in range(3):
      for i in range(2):
            ax[j].plot([0,i])
ax[0].legend(['1','2'], 
          bbox_to_anchor=(0.1, 1), 
          bbox_transform=ax[-1].transAxes, loc="upper left")
ax[-1].axis("off")
fig.set_tight_layout(True)

The subplots are in the wrong place and have the wrong size (mostly outside the figure window in my real ploting code ...) and its get even worse if you interact with them.

python 3.6
matplotlib 2.2.0 and 2.2.2 has been tested.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions