Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BUG]: Button widgets don't work in inset axes #25030

Copy link
Copy link
Closed
@QuLogic

Description

@QuLogic
Issue body actions

Summary

If I modify the check button example to put the buttons in an inset axes:

diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py
index 493ac4c3e7..574bad6780 100644
--- a/examples/widgets/check_buttons.py
+++ b/examples/widgets/check_buttons.py
@@ -23,12 +23,11 @@ fig, ax = plt.subplots()
 l0, = ax.plot(t, s0, visible=False, lw=2, color='k', label='2 Hz')
 l1, = ax.plot(t, s1, lw=2, color='r', label='4 Hz')
 l2, = ax.plot(t, s2, lw=2, color='g', label='6 Hz')
-fig.subplots_adjust(left=0.2)
 
 lines_by_label = {l.get_label(): l for l in [l0, l1, l2]}
 
 # Make checkbuttons with all plotted lines with correct visibility
-rax = fig.add_axes([0.05, 0.4, 0.1, 0.15])
+rax = ax.inset_axes([0.0, 0.0, 0.12, 0.2])
 check = CheckButtons(
     ax=rax,
     labels=lines_by_label.keys(),

then the check buttons are not responsive in the inset axes. Clicking on them does nothing.

If I just put them in a regular Axes that happens to overlay the main one, then everything works fine:

diff --git a/examples/widgets/check_buttons.py b/examples/widgets/check_buttons.py
index 493ac4c3e7..574bad6780 100644
--- a/examples/widgets/check_buttons.py
+++ b/examples/widgets/check_buttons.py
@@ -23,12 +23,12 @@ fig, ax = plt.subplots()
 l0, = ax.plot(t, s0, visible=False, lw=2, color='k', label='2 Hz')
 l1, = ax.plot(t, s1, lw=2, color='r', label='4 Hz')
 l2, = ax.plot(t, s2, lw=2, color='g', label='6 Hz')
-fig.subplots_adjust(left=0.2)
 
 lines_by_label = {l.get_label(): l for l in [l0, l1, l2]}
 
 # Make checkbuttons with all plotted lines with correct visibility
-rax = fig.add_axes([0.05, 0.4, 0.1, 0.15])
+bbox = ax.get_position()
+rax = fig.add_axes([bbox.x0, bbox.y0, 0.12, 0.2])
 check = CheckButtons(
     ax=rax,
     labels=lines_by_label.keys(),

Proposed fix

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.