8000 stairs() crashes with no values and one edge · Issue #18934 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
stairs() crashes with no values and one edge #18934
Closed
@anntzer

Description

@anntzer

Bug report

Bug summary

Currently calling stairs with no values and a single edge crashes with an AttributeError.

Code for reproduction

from pylab import *; stairs([], [0])

Actual outcome

AttributeError: 'StepPatch' object has no attribute '_path'

Expected outcome

The zero-value, single-edge case can occur naturally when using stairs to plot piecewise-constant functions (rather than pre-binned histograms), and it would seem reasonable to simply be a no-op in that case (except for adjusting the xlims to include the edge position (just like plot([0], [0]) effectively draws nothing but adjusts the data limits).
Even if we decide that we really do not want to support this case (I would disagree with such a choice), we should at least error out cleanly rather than with an obscure AttributeError.

Matplotlib version

  • Operating system:
  • Matplotlib version: master
  • Matplotlib backend (print(matplotlib.get_backend())):
  • Python version:
  • Jupyter version (if applicable):
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0