Skip to content

implement fill for connect="finite"#3071

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:finite-fill
Jun 29, 2024
Merged

implement fill for connect="finite"#3071
j9ac9k merged 2 commits intopyqtgraph:masterfrom
pijyoi:finite-fill

Conversation

@pijyoi
Copy link
Copy Markdown
Contributor

@pijyoi pijyoi commented Jun 24, 2024

Implement the fill behavior for connect="finite" as defined in #3068

@NilsNemitz
Copy link
Copy Markdown
Contributor

I have no further comments. :)

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Jun 25, 2024

this PR seems to fix #2312

baseline=None
)

if not self.opts['skipFiniteCheck']:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love that this check on skipFiniteCheck is going away!

@pijyoi
Copy link
Copy Markdown
Contributor Author

pijyoi commented Jun 25, 2024

An animation to demonstrate this PR as well as #3068

import random
import numpy as np
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore

# pg.setConfigOptions(useOpenGL=True, enableExperimental=True)

pg.mkQApp()
plt = pg.PlotWidget()
plt.show()
data = np.zeros(1000)
data[:-1] = np.nan

curve = pg.PlotCurveItem(data, connect="finite", fillLevel=0.0, brush=(50, 50, 200, 100))
plt.addItem(curve)

def update():
    val = random.gauss(0, 1)
    data[:-1] = data[1:]
    data[-1] = data[-2] + val

    # inject a nan every now and then
    if random.randrange(500) == 0:
        data[-2] = np.nan

    level = np.nanmean(data)
    curve.setData(data, fillLevel=level)

timer = QtCore.QTimer()
timer.timeout.connect(update)
timer.start(0)

pg.exec()

@pijyoi pijyoi marked this pull request as ready for review June 25, 2024 12:40
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 29, 2024

Love the diff @pijyoi thanks for simplifying one of our most used GraphicsItems.

@j9ac9k j9ac9k merged commit ce72e67 into pyqtgraph:master Jun 29, 2024
@pijyoi pijyoi deleted the finite-fill branch June 29, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants