Skip to content

subplot: get_position() and set_position() are inconsistent  #17777

@jan-janssen

Description

@jan-janssen

Bug report

Bug summary

get_position() and set_position() are inconsistent

Code for reproduction

box1 = ax1.get_position()
print(box1)
ax1.set_position([box1.x0, box1.y0, box1.x1-box1.x0, box1.y1-box1.y0])
box2 = ax1.get_position()
print(box2)
ax1.set_position([box1.x0, box1.y0, box1.x1, box1.y1])
box3 = ax1.get_position()
print(box3)

Actual outcome

Bbox(x0=0.125, y0=0.125, x1=0.9, y1=0.88)
Bbox(x0=0.125, y0=0.125, x1=0.9, y1=0.88)
Bbox(x0=0.125, y0=0.125, x1=1.025, y1=1.005)

Expected outcome

Bbox(x0=0.125, y0=0.125, x1=0.9, y1=0.88)
Bbox(x0=0.125, y0=0.125, x1=0.775, y1=0.755)
Bbox(x0=0.125, y0=0.125, x1=0.775, y1=0.755)

get_position() and set_position() should be consistent.

Matplotlib version

  • Operating system: Linux and Mac OS X
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipykernel.pylab.backend_inline
  • Python version: 3.7.6
  • Jupyter version (if applicable): 6.0.3
  • Other libraries:

I installed matplotlib via conda using the conda-forge channel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions