-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Milestone
Description
Bug summary
If an axis of the root axes are flipped (e.g. if imshow
was used), the inset axes lines may cross over each other. I believe this is because the function looks at the data coordinates of the root axes, but only the figure bounding box of the inset axes.
Code for reproduction
import numpy as np
from PIL import Image
from matplotlib.cbook import get_sample_data
from matplotlib import pyplot as plt
img = np.asarray(Image.open(get_sample_data("logo2.png", False)))
fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.imshow(img)
xmin = 160
ymin = 30
width = 75
height = 60
ax2.imshow(img[ymin:ymin+height, xmin:xmin+width])
ax1.indicate_inset(
[xmin, ymin, width, height], ax2,
edgecolor="red"
)
fig.show()
Actual outcome
Expected outcome
Connector lines should not cross
Matplotlib version
3.1.0
- Operating system: Ubuntu 16.04
- Matplotlib version: 3.1.0 (pip installed)
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.7.3
- Other libraries: numpy 1.16.4, pillow 5.3.0
Workaround
Define the inset bounding box with
[xmin, ymax, width, -height]
instead of
[xmin, ymin, width, height]
Metadata
Metadata
Assignees
Labels
No labels