Help with setting x-link

139 views
Skip to first unread message

Julio Trevisan

unread,
Mar 20, 2014, 4:55:15 PM3/20/14
to pyqt...@googlegroups.com
I am writing an application that plots several stock charts for several assets. I would like to see all the x-axis aligned so that I can visually see the correlations between the charts.

According to the "Linked Views" example, it seems that the x-axis of the plots should be aligned even if the ticks on the left axis cause one of them to have an offset. Indeed some of my charts have this offset and the linked views are aligned, but others aren't (see image attached).

Please can someone tell if this is correct behaviour, if it is a bug, a workaround, ...?

Cheers
BrazilAssets.png

Luke Campagnola

unread,
Mar 20, 2014, 9:09:02 PM3/20/14
to pyqt...@googlegroups.com
It should at least be possible to achieve perfect alignment across all of your plots. Whether your program is exhibiting the correct behavior depends on how it is written, though. 

I have one immediate guess: you have all plots linked to a single plot (probably the top-left plot?). The reason this does not align all of the plots in the right column makes sense if you understand what is really happening when plots are linked: If two linked plots are stacked vertically, then pyqtgraph can actually set the axes on these plots such that the grid lines are vertically aligned. On the other hand, if the same two plots are side-by-side, then this would be meaningless because the plots have no overlapping area along the X axis. In this case, pyqtgraph just assigns the plots to have exactly the same range along the X axis. Extending this to your example, ALL of the plots on the right side are copying the X-range of another plot in the left column, and thus they do not necessarily appear aligned with one another. 

So the solution for this is to link the two top-most plots together, and then link all of the right-column plots to the top-right plot. 

I hope that makes sense.. If I have guessed your problem incorrectly, then I'll need to see a code example to be more helpful.


Luke

Julio Trevisan

unread,
Mar 21, 2014, 8:06:21 AM3/21/14
to pyqt...@googlegroups.com
Hi Luke
Thank you very much for your answer. It works now! You guessed exactly how I was trying to do and your explanation made complete sense. I am now linking the plots column-wise: I link all plots at one column to the top-most plot of that column (see attached screenshot if you are interested in the final result).

Julio


Yes, it made complete sense.
 


Luke

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/CACZXET_kcZNZXa7aJCwxGPMbNCTRh67KvU04EDtANhs%3DvoTbYQ%40mail.gmail.com.

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

BrazilAssets2.png

Upol Ryskulova

unread,
Mar 27, 2015, 10:53:05 AM3/27/15
to pyqt...@googlegroups.com
Hello Luke & Julio,
I am having trouble in aligning two graphs'  y-axis. I do not have problem in aligning grids as you discussed here. But I want to push my graph's look one step further. I attached my graph image below. It plots real time graphs , I linked just x-axises. When I link y-axises this alignment issue disappears but larger range is scaled to smaller range. In this case when y-axises linked upper graph's range became 50. I am newbie in qt and pyqtgraph. I will be very grateful.
Thank you.
Regards,
Upol
graph1.png

Upol Ryskulova

unread,
Mar 28, 2015, 5:56:00 AM3/28/15
to pyqt...@googlegroups.com
Hello again,
I have solved this alingment problem by using setContentsMargins function. Thank you.

--
You received this message because you are subscribed to a topic in the Google Groups "pyqtgraph" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyqtgraph/gD4i-EQMtiY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyqtgraph+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyqtgraph/7409534a-8193-4c56-939d-f8376c608d04%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages