|
9 | 9 | from matplotlib.backend_bases import MouseEvent
|
10 | 10 | from matplotlib.colors import LogNorm
|
11 | 11 | from matplotlib.patches import Circle, Ellipse
|
12 |
| -from matplotlib.transforms import Bbox, TransformedBbox |
| 12 | +from matplotlib.transforms import Affine2D, Bbox, TransformedBbox |
13 | 13 | from matplotlib.testing.decorators import (
|
14 | 14 | check_figures_equal, image_comparison, remove_ticks_and_titles)
|
15 | 15 |
|
|
26 | 26 | from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
|
27 | 27 | from mpl_toolkits.axes_grid1.inset_locator import (
|
28 | 28 | zoomed_inset_axes, mark_inset, inset_axes, BboxConnectorPatch)
|
| 29 | +from mpl_toolkits.axes_grid1.parasite_axes import HostAxes |
29 | 30 | import mpl_toolkits.axes_grid1.mpl_axes
|
30 | 31 | import pytest
|
31 | 32 |
|
@@ -467,6 +468,26 @@ def test_gettightbbox():
|
467 | 468 | [-17.7, -13.9, 7.2, 5.4])
|
468 | 469 |
|
469 | 470 |
|
| 471 | +def test_gettightbbox_parasite(): |
| 472 | + fig = plt.figure() |
| 473 | + |
| 474 | + y0 = 0.3 |
| 475 | + horiz = [Size.Scaled(1.0)] |
| 476 | + vert = [Size.Scaled(1.0)] |
| 477 | + ax0_div = Divider(fig, [0.1, y0, 0.8, 0.2], horiz, vert) |
| 478 | + ax1_div = Divider(fig, [0.1, 0.5, 0.8, 0.4], horiz, vert) |
| 479 | + |
| 480 | + ax0 = fig.add_subplot( |
| 481 | + xticks=[], yticks=[], axes_locator=ax0_div.new_locator(nx=0, ny=0)) |
| 482 | + ax1 = fig.add_subplot( |
| 483 | + axes_class=HostAxes, axes_locator=ax1_div.new_locator(nx=0, ny=0)) |
| 484 | + aux_ax = ax1.get_aux_axes(Affine2D()) |
| 485 | + |
| 486 | + fig.canvas.draw() |
| 487 | + rdr = fig.canvas.get_renderer() |
| 488 | + assert rdr.get_canvas_width_height()[1] * y0 / fig.dpi == fig.get_tightbbox(rdr).y0 |
| 489 | + |
| 490 | + |
470 | 491 | @pytest.mark.parametrize("click_on", ["big", "small"])
|
471 | 492 | @pytest.mark.parametrize("big_on_axes,small_on_axes", [
|
472 | 493 | ("gca", "gca"),
|
|
0 commit comments