Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Description
Bug summary
The current implementation seems to assume that the lower leftll
, upper leftul
, and lower rightlr
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
importnumpyasnpfrommatplotlib.transformsimportAffine2D,Bbox# Switch 'x' and 'y' coordinatesT=Affine2D(np.array([ [0,1,0], [1,0,0], [0,0,1] ]) )# Unit vectorspts=np.array([ [1,0], [0,1]])# Produce a Bbox from the unit vectorsbb=Bbox.null()bb.update_from_data_xy(pts)# Resultbb.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.0bb.transformed( T ).width == 1.0
Additional information
The current implementation (v3.8.0) seems to assume that the lower leftll
, upper leftul
, and lower rightlr
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