Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add tests for mpl_toolkit anchored artists #23863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 31 additions & 1 deletion lib/mpl_toolkits/axes_grid1/tests/test_axes_grid1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from matplotlib import cbook
from matplotlib.backend_bases import MouseEvent
from matplotlib.colors import LogNorm
from matplotlib.patches import Circle, Ellipse
from matplotlib.transforms import Bbox, TransformedBbox
from matplotlib.testing.decorators import (
check_figures_equal, image_comparison, remove_ticks_and_titles)
Expand All @@ -16,7 +17,8 @@
host_subplot, make_axes_locatable,
Grid, AxesGrid, ImageGrid)
from mpl_toolkits.axes_grid1.anchored_artists import (
AnchoredSizeBar, AnchoredDirectionArrows)
AnchoredAuxTransformBox, AnchoredDrawingArea, AnchoredEllipse,
AnchoredDirectionArrows, AnchoredSizeBar)
from mpl_toolkits.axes_grid1.axes_divider import (
Divider, HBoxDivider, make_axes_area_auto_adjustable, SubplotDivider,
VBoxDivider)
Expand Down Expand Up @@ -499,6 +501,34 @@ def on_pick(event):
assert small in event_rects


@image_comparison(['anchored_artists.png'], remove_text=True, style='mpl20')
def test_anchored_artists():
fig, ax = plt.subplots(figsize=(3, 3))
ada = AnchoredDrawingArea(40, 20, 0, 0, loc='upper right', pad=0.,
frameon=False)
p1 = Circle((10, 10), 10)
ada.drawing_area.add_artist(p1)
p2 = Circle((30, 10), 5, fc="r")
ada.drawing_area.add_artist(p2)
ax.add_artist(ada)

box = AnchoredAuxTransformBox(ax.transData, loc='upper left')
el = Ellipse((0, 0), width=0.1, height=0.4, angle=30, color='cyan')
box.drawing_area.add_artist(el)
ax.add_artist(box)

ae = AnchoredEllipse(ax.transData, width=0.1, height=0.25, angle=-60,
loc='lower left', pad=0.5, borderpad=0.4,
frameon=True)
ax.add_artist(ae)

asb = AnchoredSizeBar(ax.transData, 0.2, r"0.2 units", loc='lower right',
pad=0.3, borderpad=0.4, sep=4, fill_bar=True,
frameon=False, label_top=True, prop={'size': 20},
size_vertical=0.05, color='green')
ax.add_artist(asb)


def test_hbox_divider():
arr1 = np.arange(20).reshape((4, 5))
arr2 = np.arange(20).reshape((5, 4))
Expand Down