Closed
Description
Bug report
Bug summary
The window extent of the axes does not coincide with their position in the figure. This issue occurs in Agg and Cairo backends.
Code for reproduction
The following code produces two axes. A green rectangle is drawn at the bounding box of the axes. A red rectangle is drawn in the space between the axes.
import matplotlib.pyplot as plt
fig, axs = plt.subplots(2, figsize=(4,2), dpi=100)
for ax in axs.flatten():
ax.set(xticklabels = [], yticklabels=[])
ax.tick_params(labelbottom=False, bottom=False)
fig.canvas.draw()
bb1 = axs[0].get_window_extent()
bb2 = axs[1].get_window_extent()
rect = plt.Rectangle((bb2.x0, bb2.y1), width=20, height=bb1.y0 - bb2.y1,
linewidth=72./fig.dpi, edgecolor="red", facecolor="none",
transform=None)
rect2 = plt.Rectangle((bb2.x0, bb2.y0), width=bb2.width, height=bb2.height,
linewidth=72./fig.dpi, edgecolor="limegreen", facecolor="none",
transform=None)
fig.add_artist(rect2)
fig.add_artist(rect)
fig.savefig("borders.png")
plt.show()
Actual outcome
The green rectangle does not overlay with the axes. The red rectangle does not sit tight on both axes.
Expected outcome
The green rectangle should appear exactly on top of the axes spines. The red rectangle should sit tight on both axes.
Matplotlib version
- Operating system: Win8
- Matplotlib version: master
- Matplotlib backend: Qt5Agg, TkCairo
- Python version: 3.6.6