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

Skip to content

examples/widgets/span_selector.py is brittle #20200

Closed
@anntzer

Description

@anntzer

Problem

examples/widgets/span_selector.py crashes if one clicks somewhere and immediately releases the click, without dragging the SpanSelector, with

Traceback (most recent call last):
  File ".../matplotlib/lib/matplotlib/cbook/__init__.py", line 274, in process
    func(*args, **kwargs)
  File ".../matplotlib/lib/matplotlib/widgets.py", line 1840, in release
    self._release(event)
  File ".../matplotlib/lib/matplotlib/widgets.py", line 2069, in _release
    self.onselect(vmin, vmax)
  File ".../matplotlib/examples/widgets/span_selector.py", line 36, in onselect
    ax2.set_xlim(region_x[0], region_x[-1])
IndexError: index 0 is out of bounds for axis 0 with size 0

Suggested Improvement

Make the example more robust.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.4+HEAD
  • Matplotlib documentation version (is listed under the logo): 3.4.2.post693

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationGood first issueOpen a pull request against these issues if there are no active ones!

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions