Adding support for connect PlotItem connect vector during view clippng and downsampling
When using the connect vector argument to plot (PlotItem) one can not use ClitToView or Downsampling. Using them will cause an Exception (ValueError):
E.g running this code and activating "clip to view" or downsampling via right click menu:
import numpy as np
import pyqtgraph as pg
x = np.linspace(0.0, 7.0, num=10000)
x = np.concatenate((x[:3000], x[7000:]))
y = np.sin(x)
c = np.ones(len(x), dtype=bool)
c[2999] = False
pg.plot(x,y, connect=c)
if __name__ == '__main__':
pg.exec()
This PR "fixes" that. Clipping works as expected. Down-sampling will no linger cast exception. Don't know if it is the best strategy for down-sampling the connect vector. But I didn't want to make the calculations too expensive.
Best regards Troels Blum
I also create a patch for version 13.7 since that is the version installed by pip (and that I am using) Don't know if that is useful? pyqtgraph_connect.patch
Hi @tblum
Thanks for this PR, this change LGTM.
Can you add a test in test_PlotDataItem.py that will demonstrate this functionality? There is a test_clipping function there already, maybe would benefit from parameterizing x, y and connect arguments. Let mek now if you would need some guidance.
Thanks for the PR!
Updated the doc-string and added a test based on the example I posted.
@j9ac9k Am I missing something, or is this good to go?
Hi @tblum
Thanks for the PR, sorry this has taken me so long to get to it. This LGTM, merging!