Auto-pan speed

459 views
Skip to first unread message

Largerhats

unread,
Nov 28, 2013, 5:32:10 PM11/28/13
to pyqt...@googlegroups.com
Hello,

I am using pyqtgraph in Python 2.7, plotting data streaming in real-time from a wireless device.  I have encountered a persistent problem with the auto-pan setting where, as the plotted line extends to the right and the view auto-pans to follow the data, eventually it falls behind and end of the plotted data line extends off screen.  It continues to pan to the right at a consistent rate, but is no longer showing the most recent data.

I tried improving the performance of the plotting through suggestions on this site and others, which definitely helped with the speed and efficiency of the plotting, but didn't resolve the issue of getting the auto-pan to keep up with the data stream.  It may not be relevant, but auto-scaling does not suffer from the same issue.

How do I change the speed of the auto-pan to keep up with my data?  Is it even possible?  The documentation I read didn't seem to indicate as such.

Thanks in advance for your help and suggestions.

Cheers

Luke Campagnola

unread,
Dec 1, 2013, 10:59:57 AM12/1/13
to pyqt...@googlegroups.com
On Thu, Nov 28, 2013 at 5:32 PM, Largerhats <large...@gmail.com> wrote:
I am using pyqtgraph in Python 2.7, plotting data streaming in real-time from a wireless device.  I have encountered a persistent problem with the auto-pan setting where, as the plotted line extends to the right and the view auto-pans to follow the data, eventually it falls behind and end of the plotted data line extends off screen.  It continues to pan to the right at a consistent rate, but is no longer showing the most recent data.

I tried improving the performance of the plotting through suggestions on this site and others, which definitely helped with the speed and efficiency of the plotting, but didn't resolve the issue of getting the auto-pan to keep up with the data stream.  It may not be relevant, but auto-scaling does not suffer from the same issue.

There are many possible explanations for this.. it would be best if you can provide a working example so we can see exactly what it going wrong. If that is not possible, we might be able to help if you can post the relevant code.

Luke


 

Largerhats

unread,
Dec 2, 2013, 1:10:24 PM12/2/13
to pyqt...@googlegroups.com
On Sunday, 1 December 2013 10:59:57 UTC-5, Luke Campagnola wrote:
There are many possible explanations for this.. it would be best if you can provide a working example so we can see exactly what it going wrong. If that is not possible, we might be able to help if you can post the relevant code.
Luke

 Hi Luke,

I have a working example here that should help illustrate my issue.  Thanks for your response.
pan_speed_example.py

Luke Campagnola

unread,
Dec 2, 2013, 5:21:36 PM12/2/13
to pyqt...@googlegroups.com
Thank you, I understand now. 
The problem is that auto-pan is designed to center the view on the average value of an axis without changing the width of the view range. I can see how the terminology "auto pan" is confusing in this case. 

Possible solutions:
- The easiest solution is just to call self.plot1.setXRange() manually after each update, but then you lose the ability to interactively explore the data. 

- This could be corrected by some mechanism allowing the user to enable/disable automatic panning (perhaps overriding the behavior of the "A" button in the PlotItem, or adding a new button there)

- Possibly ViewBox could be given a new option specifying whether it should auto-pan to the (min, mean, median, max)


Luke

Largerhats

unread,
Dec 3, 2013, 9:23:04 AM12/3/13
to pyqt...@googlegroups.com
On Monday, 2 December 2013 17:21:36 UTC-5, Luke Campagnola wrote:

Thank you, I understand now. 
The problem is that auto-pan is designed to center the view on the average value of an axis without changing the width of the view range. I can see how the terminology "auto pan" is confusing in this case. 

Possible solutions:
- The easiest solution is just to call self.plot1.setXRange() manually after each update, but then you lose the ability to interactively explore the data. 

- This could be corrected by some mechanism allowing the user to enable/disable automatic panning (perhaps overriding the behavior of the "A" button in the PlotItem, or adding a new button there)

- Possibly ViewBox could be given a new option specifying whether it should auto-pan to the (min, mean, median, max)


Luke

Luke,

Thanks again for your help.  This is exactly the clarification I needed.

Cheers

Alex Schueth

unread,
May 17, 2016, 1:15:18 PM5/17/16
to pyqtgraph
Sorry to revive this 3 years later, but did you ever find a solution that would pan to the latest data point but would still allow interactivity?

cloudo...@gmail.com

unread,
Oct 2, 2018, 3:43:29 AM10/2/18
to pyqtgraph
Dear All,

I have been scouring the stackoverflow and this forums for a solution to the above original question, but have not found anything usable. Is it possible to create a chart that auto-pans the x-axis to see the latest data?
I am trying to do something like the demo in this link: https://peque.github.io/EuroPython-Bilbao-2016/video/gui_chart.webm ,(from the 00:15 mark to the end), where one can still interactively explore the data. I believe it is done similar to what Luke mentioned above (5years ago), with a button to do a  custom-type auto-pan to last input data on right of x-axis. I am using the customGraphicsItem.py example from the pyqtgraph github, as base.I would really appreciate if someone could help me on this, as I am somewhat new to pyqtgraph.
Thanks in advance

Carlos Pascual

unread,
Oct 2, 2018, 8:22:28 AM10/2/18
to pyqt...@googlegroups.com, cloudo...@gmail.com
I created something similar for my my taurus_pyqtgraph project
(https://github.com/taurus-org/taurus_pyqtgraph)

Here is a demo snippet which that can be tested without taurus:

https://gist.github.com/cpascual/ce1cfc30c9d4596bfaa41d16a9ca5d6a


On Tuesday, October 2, 2018 12:43:29 AM CEST cloudo...@gmail.com wrote:
> Dear All,
>
> I have been scouring the stackoverflow and this forums for a solution to
> the above original question, but have not found anything usable. Is it
> possible to create a chart that auto-pans the x-axis to see the latest data?
> I am trying to do something like the demo in this link:
> https://peque.github.io/EuroPython-Bilbao-2016/video/gui_chart.webm ,(from
> the 00:15 mark to the end), where one can still interactively explore the
> data. I believe it is done similar to what Luke mentioned above (5years
> ago), with a button to do a custom-type auto-pan to last input data on
> right of x-axis. I am using the customGraphicsItem.py example from the
> pyqtgraph github, as base.I would really appreciate if someone could help
> me on this, as I am somewhat new to pyqtgraph.
> Thanks in advance
>
> On Tuesday, May 17, 2016 at 5:15:18 PM UTC, Alex Schueth wrote:
> > Sorry to revive this 3 years later, but did you ever find a solution that
> > would pan to the latest data point but would still allow interactivity?
> >
> > On Tuesday, December 3, 2013 at 8:23:04 AM UTC-6, Largerhats wrote:
> >> On Monday, 2 December 2013 17:21:36 UTC-5, Luke Campagnola wrote:
> >>> Thank you, I understand now.
> >>> The problem is that auto-pan is designed to center the view on the
> >>> *average* value of an axis without changing the width of the view
> >>> range. I can see how the terminology "auto pan" is confusing in this
> >>> case.
> >>>
> >>> Possible solutions:
> >>> - The easiest solution is just to call self.plot1.setXRange() manually
> >>> after each update, but then you lose the ability to interactively
> >>> explore
> >>> the data.
> >>>
> >>> - This could be corrected by some mechanism allowing the user to
> >>> enable/disable automatic panning (perhaps overriding the behavior of the
> >>> "A" button in the PlotItem, or adding a new button there)
> >>>
> >>> - Possibly ViewBox could be given a new option specifying whether it
> >>> should auto-pan to the (min, mean, median, max)
> >>>
> >>>
> >>> Luke
> >>
> >> Luke,
> >>
> >> Thanks again for your help. This is exactly the clarification I needed.
> >>
> >> Cheers


--
+----------------------------------------------------+
Carlos Pascual Izarra
Scientific Software Coordinator
Computing Division
ALBA Synchrotron [http://www.albasynchrotron.es]
Carrer de la Llum 2-26
E-08290 Cerdanyola del Valles (Barcelona), Spain
E-mail: cpas...@cells.es
Phone: +34 93 592 4428
+----------------------------------------------------+

cloudo...@gmail.com

unread,
Oct 3, 2018, 12:13:56 AM10/3/18
to pyqtgraph
Hi Carlos,
Thank you so much for your post. I tried the demo without the taurus, I replaced PyQt4 with pyqtgraph, and it works great. 
I am still studying your demo code to see if I can use it as a base class to create the effect as in the demo: https://peque.github.io/EuroPython-Bilbao-2016/video/gui_chart.webm , as I notice your demo pans the x-axis after a certain period of time.
Could you advise me how to pan the chart with every new update point, as opposed to by time? That is, with a new point, it pans right. My use case is to chart forex market data as it streams in.

Thank you so much,
Cloud Ostrich

Carlos Pascual

unread,
Oct 3, 2018, 3:25:14 AM10/3/18
to pyqt...@googlegroups.com


On October 3, 2018 6:13:56 AM GMT+02:00, cloudo...@gmail.com wrote:

>Could you advise me how to pan the chart with every new update point,
>as
>opposed to by time? That is, with a new point, it pans right.


In my case i used a time trigger for 2 reasons:
- efficiency (in my apps it is common to get thousands of new points per second)
- isolation: i wanted to implement it as a tool that does not require any extra config to be usable other than to attach it to an existing plot.

But if you do not have those constraints, just call the updateRange method whenever you are processing a new incoming event.

I hope this helps

cloudo...@gmail.com

unread,
Oct 5, 2018, 1:59:33 AM10/5/18
to pyqtgraph
Dear Carlos,
Sorry for late reply. I added a line "autopan.updateRange()" in the addPoint function, and deleted all timer lines in the XAutoPanTool class. It worked fantastic. Thank you so much for your help. It was invaluable, as I am still a noob. Don't know how to thank you enough... was stuck in this problem for about 2 weeks now. Would like to buy you a beer if there is a chance. :)

Carlos Pascual

unread,
Oct 5, 2018, 9:37:54 AM10/5/18
to pyqt...@googlegroups.com, cloudo...@gmail.com
No worries,
Cheers!
Reply all
Reply to author
Forward
0 new messages