Skip to content

fill_between, step='post' and NaN #19444

Closed as not planned
Closed as not planned
@mankoff

Description

@mankoff

Off-by-one error if using fill_between, step='post'

import matplotlib.pyplot as plt
import pandas as pd

fig = plt.figure(1)
ax = fig.add_subplot(111)

df = pd.DataFrame(index=pd.date_range(start='2000-01-01', periods=10, freq='1D'))
df['data'] = [1,2,3,-4,-5,-6,7,8,9,-10]

df.plot(ax=ax, drawstyle='steps-post')
ax.fill_between(df[df > 0].index, df[df > 0].values.flatten(), step='post')

Actual outcome

image

Expected outcome

Some of the df[df > 0] columns are not filled.

Matplotlib version

  • Operating system: Linux Kubuntu 20.04
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): 3.3.1
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.5
  • Jupyter version (if applicable): IPython 7.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions