X Tutup
Skip to content

axes set_position ignored if using tight_layout  #8337

@billtau

Description

@billtau

Bug report

Bug summary

  • The set_position() seems to be ignored if using tight_layout()
  • A similar effect is observed when putting subplots_adjust() after set_position (see the code comment).

Code for reproduction

# Paste your code here
import matplotlib.pyplot as plt
import numpy.random as random

data = random.randn(255,255)

plt.close()

fig,axes = plt.subplots(2,1)

ax=axes[0]

im=ax.imshow(data, aspect='auto')
cb=plt.colorbar(im, ax=ax)
ax.set_xlabel('X data')
ax.set_ylabel('Y data')

pos0 = ax.get_position()

ax=axes[1]
pos1 = ax.get_position()
ax.set_position([pos1.x0, pos1.y0, pos0.width, pos1.height])

ax.plot([0,1])
ax.set_xlabel('Big')
ax.set_ylabel('Small')

plt.tight_layout() # put  plt.subplots_adjust(left=0.2) here produces similar results

plt.show()

Actual outcome

a_wrong

Expected outcome

a_correct

Matplotlib version

  • Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)
    Matplotlib 2.0.0, OSX
  • How did you install Matplotlib and Python (pip, anaconda, from source ...)
    MacPorts

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup