step mode and downsampling + clip to view

677 views
Skip to first unread message

Marija Zupunski

unread,
Feb 7, 2017, 11:38:18 AM2/7/17
to pyqtgraph
Hi guys,

I would like to draw plot items using stepMode=True and after that I would like to use setDownsampling() and setClipToView(). I have exception when i send data saying that:

"len(X) must be len(Y)+1 since stepMode=True"

I set length of x and y values, but still I have the same exception when I call setDownsampling() and setClipToView()

My code is something like this:


# len(x_value) == len(y_value)
self.subplot.plot(x=signal.x_value, y=signal.y_value[:-1], pen=signal.color, name=signal.name, stepMode=True)
self.subplot.setDownsampling(ds=True, auto=False, mode='peak')
self.subplot.setClipToView(clip=True)


Is there something wrong that I am doing? 

vas...@gmail.com

unread,
Feb 7, 2017, 6:32:44 PM2/7/17
to pyqt...@googlegroups.com

On Tue, Feb 7, 2017 at 5:38 PM, Marija Zupunski <marija....@gmail.com> wrote:
setClipToView


Maybe to try wih setClipToView(True)  without 'clip='?

Marija Zupunski

unread,
Feb 8, 2017, 8:38:56 AM2/8/17
to pyqtgraph
Vasilije, I tried that but I think that is not a problem. 

Here is what I have tried and some of my conclusions:

1. setDownsampling(ds=True, auto=False, mode='peak') method should be called only after creating PlotItem not after every plot()
2. attribute auto must be False, otherwise I have exception earlier mention
3. I tried calling method setClipToView(True) also only after creating PlotItem (not after every plot) but no luck - same exception ("len(X) must be len(Y)+1 since stepMode=True")

So downsampling just once and not using clip to view solves exception in use case where I want to plot two PlotDataItem (one has stepMode=True, other=False) on same PlotItem. 

Also when I had exception there is also some ignored exceptions that weren't by biggest problem but I would point that out.

vas...@gmail.com

unread,
Feb 8, 2017, 10:03:35 PM2/8/17
to pyqt...@googlegroups.com
Look at the scrolling plot example you have in the examples directory.

Original rows are:
curve1 = p1.plot(data1)
curve2 = p2.plot(data1)

This make exception:
curve1 = p1.plot(data1, stepMode = True)
This also make exception:
curve2 = p2.plot(data1, stepMode = True)

From documentation:
http://www.pyqtgraph.org/documentation/graphicsItems/plotcurveitem.html
stepMode If True, two orthogonal lines are drawn for each sample as steps. This is commonly used when drawing histograms. Note that in this case, len(x) == len(y) + 1

so, if you decide to use curve2 with stepMode enabled, initialize it with:
curve2 = p2.plot(stepMode = True)  # without data1 as parameter!!!
and be sure that you calling setData for curve2 (for example) as:
curve2.setData(y=data1, x=range(len(data1)+1))


--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/9639a623-d481-4b3a-b38d-080a0bad578a%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

scrollingPlots.py
scrollingPlots_curve2_stepMode_enabled.py

Marija Zupunski

unread,
Feb 14, 2017, 9:19:57 AM2/14/17
to pyqtgraph
Hi Vasilije,

I used your suggestions and made a small test. I still have exception ("len(X) must be len(Y)+1 since stepMode=True (got (0L,) and (0L,))") when I zoom in/out my plot. In attachment is my test case scenario. 
my_case.py

vas...@gmail.com

unread,
Feb 14, 2017, 10:52:25 AM2/14/17
to pyqt...@googlegroups.com
set first, plot after that

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+unsubscribe@googlegroups.com.

Marija Zupunski

unread,
Feb 15, 2017, 9:11:57 AM2/15/17
to pyqtgraph
Hi Vasilije,

I tried every combination and in all cases I have the same exception. :( This test that I sent you is working when there is no setClipToView but with that method turned on, before or after plotting, I have exception.


On Tuesday, February 14, 2017 at 4:52:25 PM UTC+1, Vasilije Mehandzic wrote:
set first, plot after that
On Tue, Feb 14, 2017 at 3:19 PM, Marija Zupunski <marija....@gmail.com> wrote:
Hi Vasilije,

I used your suggestions and made a small test. I still have exception ("len(X) must be len(Y)+1 since stepMode=True (got (0L,) and (0L,))") when I zoom in/out my plot. In attachment is my test case scenario. 


On Tuesday, February 7, 2017 at 5:38:18 PM UTC+1, Marija Zupunski wrote:
Hi guys,

I would like to draw plot items using stepMode=True and after that I would like to use setDownsampling() and setClipToView(). I have exception when i send data saying that:

"len(X) must be len(Y)+1 since stepMode=True"

I set length of x and y values, but still I have the same exception when I call setDownsampling() and setClipToView()

My code is something like this:


# len(x_value) == len(y_value)
self.subplot.plot(x=signal.x_value, y=signal.y_value[:-1], pen=signal.color, name=signal.name, stepMode=True)
self.subplot.setDownsampling(ds=True, auto=False, mode='peak')
self.subplot.setClipToView(clip=True)


Is there something wrong that I am doing? 

--
You received this message because you are subscribed to the Google Groups "pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyqtgraph+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages