Associating a data set with the 2nd y axis of the same plot

313 views
Skip to first unread message

Todd Batzler

unread,
Jun 18, 2014, 11:20:33 AM6/18/14
to pyqt...@googlegroups.com
The attached file is a modified version of the crosshair example.

I'm sure this is 'simple' to someone that has more python/pyqtgraph experience than this newbie.
Using other examples for reference I was able to figure out how to create and label a second right-side y axis but can't figure out how to take the data2 data set and get it to plot on the same window with data set data1, but associated to the right y axis.

The problem in my application is data set data1 in 'real life' will be large values (+-1000 amps) and data set data2 will be small (+-5) but they share the same x axis relationship.
The second plot (plot2) is just meant to be a zoomed version of the first plot(plot1) where I want both the 'left' and 'right' plots of the top plot window to scale with the same X axis.

Please, teach me!

Alternate plot emf.py

Luke Campagnola

unread,
Jun 18, 2014, 11:51:27 AM6/18/14
to pyqt...@googlegroups.com
On Wed, Jun 18, 2014 at 11:20 AM, Todd Batzler <toddb...@gmail.com> wrote:
The attached file is a modified version of the crosshair example.

I'm sure this is 'simple' to someone that has more python/pyqtgraph experience than this newbie.
Using other examples for reference I was able to figure out how to create and label a second right-side y axis but can't figure out how to take the data2 data set and get it to plot on the same window with data set data1, but associated to the right y axis.

You're almost there. Look closely at the bottom of examples/MultiplePlotAxes.py -- There are three PlotCurveItems being created, and they are each added to a different ViewBox. The first one is created and added automatically by calling PlotItem.plot(...), and the second two must be created and added manually because there are not PlotItems representing p2 and p3 ViewBoxes.


Todd Batzler

unread,
Jun 18, 2014, 1:49:24 PM6/18/14
to pyqt...@googlegroups.com
Thanks, with those bread crumbs I was able to get it to work.
Can you recommend additional documentation or references covering this kind of material?

Also, a more subtle issue:
I noticed that when the entire LinearRegionItem is slid back and forth in the x direction with a left mouse click and hold that the X axis values of the second 'zoomed' plot change as defined by the extents of the linear region.  If I just change the extents of the linear region in the first plot, the values in the second plot are zoomed in/out respectively, but the X axis values do not update until I do a left-click hold and slight move of the linear region in the first plot, or the same action anywhere in the second plot.  Then the X axis values of the second plot get updated to those defined by the linear region in the first plot.

Can you provide some additional clues on how to get the X axis value of the second plot window to update when the upper or lower bounds of the linear region are changed?
Reply all
Reply to author
Forward
0 new messages