Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Bbox transformed method produces unexpected results #27151

Copy link
Copy link
Open
@inferentialist

Description

@inferentialist
Issue body actions

Bug summary

The current implementation seems to assume that the lower left ll, upper left ul, and lower right lr corners are preserved under transformation. This need not be the case. For example, an affine transformation that simply switches coordinates produces a wrong result.

Code for reproduction

import numpy as np
from matplotlib.transforms import Affine2D, Bbox

# Switch 'x' and 'y' coordinates
T   = Affine2D( 
        np.array([
          [0,1,0],
          [1,0,0],
          [0,0,1]
        ])
      )

# Unit vectors
pts = np.array([
  [1, 0],
  [0, 1]
])

# Produce a Bbox from the unit vectors
bb = Bbox.null()
bb.update_from_data_xy(pts)

# Result
bb.transformed( T )

Actual outcome

In [84]: bb.transformed( T )
Out[84]: Bbox([[0.0, 0.0], [0.0, 0.0]])

Expected outcome

bb.transformed( T ).height == 1.0
bb.transformed( T ).width == 1.0

Additional information

The current implementation (v3.8.0) seems to assume that the lower left ll, upper left ul, and lower right lr corners are preserved under transformation. A more general solution should probably transform each corner and fully recompute the bounding box.

Operating system

linux

Matplotlib Version

3.8.0

Matplotlib Backend

TkAgg

Python version

3.11.5

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.