Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyQtgraph live plot does not update #259

Closed
AdriaanRol opened this issue Jul 12, 2016 · 24 comments
Closed

PyQtgraph live plot does not update #259

AdriaanRol opened this issue Jul 12, 2016 · 24 comments

Comments

@AdriaanRol
Copy link
Contributor

Issue made to get rid of the hack in PR #250 .

Steps to reproduce

  1. Run Tutorial notebook from Tutorial, presentation + notebook #250
data = qc.Loop(c0.sweep(-20,20,0.1), delay=0.003).each(meter.amplitude).run(name='testsweep')
plotQ = qc.QtPlot()
plotQ.add(data.meter_amplitude)

Expected behaviour

Expect to see a live updating plot of the data

Actual behaviour

Plots only what is in "data" the moment the plot function is called.

Workaround

while data.sync():
    plotQ.update()
plotQ.update()

The following code will keep updating the plot (in the main thread) while the data taking is not finished yet.

System

operating system
OS X El Capitan 10.11.5 (15F34)
qcodes branch
"examples" (only contains notebook so should be close to master)
qcodes commit
Commit: 007e5f9

@peendebak
Copy link
Contributor

It will be good to combine this issue with #155

@MerlinSmiles
Copy link
Contributor

I'm pretty sure this is due to the HiddenUpdateWidget in base.py in the plots folder, this is basically a javascript widget that is hidden and calls the update() with a given timing.
I had issues with that before, and got rid of it in my local QtPlot and replaced it with pyqts SingleShot timer functions. This works like a charm.

So far I hadn't time to finish my other additions to QtPlot so its not ready to be merged. But I guess it would be easy to extract this into a separate PR.

@AdriaanRol
Copy link
Contributor Author

@MerlinSmiles I would be very interested in seeing if your solution solves the problem.
I am not such a big fan of the split in development proposed in #155, I'd rather have the core features work regardless of backend. But I'll see where that is headed.

@giulioungaretti
Copy link
Contributor

@AdriaanRol yes, at least in the long run that's the goal :D
and @AdriaanRol, do you see anything in the notebook terminal output ?

@AdriaanRol
Copy link
Contributor Author

No, Don't see anything

@MerlinSmiles
Copy link
Contributor

@AdriaanRol I did a very minor cleanup, so there is a lot of hacky stuff in there, but could you try the feature/pyqtgraph_improvements branch and the QtPlot example notebook in there?

@AdriaanRol
Copy link
Contributor Author

@MerlinSmiles , I could not find your notebook QtPlot example in there. I tried running the regular example notebook but that didn't work (I assumed your fix would also apply there). To make sure we are talking about the same state of the repository I got git hash 7d41c55 .

@MerlinSmiles
Copy link
Contributor

@MerlinSmiles
Copy link
Contributor

And no, it wont replace the normal QtPlot, as I still wanted that for comparison (if I remember right)

@AdriaanRol
Copy link
Contributor Author

Excuse me, probably a typo on my end.

I found it now, however upon running the first cell I run into qtawesome (I guess that is something you made?) Could there be some hidden path dependencies in there ?


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-055bead46bf1> in <module>()
      6 import pyqtgraph as pg
      7 
----> 8 from qcodes.plots.pyqtgraph_plot import QtPlot
      9 
     10 import qcodes as qc

/Users/Adriaan/GitHubRepos/DiCarloLab_Repositories/Qcodes/qcodes/plots/pyqtgraph_plot.py in <module>()
     15 from pyqtgraph.widgets import PlotWidget
     16 import pyqtgraph.dockarea as pg_dockarea
---> 17 import qtawesome as qta
     18 
     19 import warnings

ImportError: No module named 'qtawesome'

@MerlinSmiles
Copy link
Contributor

ah shoot
you can comment it out, its nothing I made but has nice icons and stuff I wanted to use for toolbar stuff...

@MerlinSmiles
Copy link
Contributor

its here: https://pypi.python.org/pypi/QtAwesome

@AdriaanRol
Copy link
Contributor Author

@MerlinSmiles I figured pip install qtawesome would be faster than commenting out stuff :)

Nonetheless I now run into a bug in cell # 3.

c0, c1, c2, vsd = gates.chan0, gates.chan1, gates.chan2, source.amplitude


data2 = qc.Loop(c1[-15:15:1],0.001).loop(c0.sweep(30,15,1),0.001).each(
    meter.amplitude, # first measurement, at c2=0 -> amplitude_0 bcs it's action 0
    qc.Task(c2.set, 1), # action 1 -> c2.set(1)
    meter.amplitude, # second measurement, at c2=1 -> amplitude_4 bcs it's action 4
    qc.Task(c2.set, 0)
    ).run(location='data/test2dx', overwrite=True)

plot2Q = QtPlot(data2.chan0, data2.chan1, data2.amplitude_0,name=data2.location)
DataSet:
   mode     = DataMode.PULL_FROM_SERVER
   location = 'data/test2dx'
   <Type>   | <array_id>  | <array.name> | <array.shape>
   Setpoint | chan1       | chan1        | (30,)
   Setpoint | chan0       | chan0        | (30, 16)
   Measured | amplitude_0 | amplitude    | (30, 16)
   Measured | amplitude_2 | amplitude    | (30, 16)
started at 2016-07-13 13:57:17
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-d2cbecc82148> in <module>()
     10     ).run(location='data/test2dx', overwrite=True)
     11 
---> 12 plot2Q = QtPlot(data2.chan0, data2.chan1, data2.amplitude_0,name=data2.location)

/Users/Adriaan/GitHubRepos/DiCarloLab_Repositories/Qcodes/qcodes/plots/pyqtgraph_plot.py in __init__(self, figsize, position, interval, windowTitle, theme, show_window, parent, *args, **kwargs)
    203 
    204         if args or kwargs:
--> 205             self.add(*args, **kwargs)
    206 
    207         QtGui.QApplication.processEvents()

/Users/Adriaan/GitHubRepos/DiCarloLab_Repositories/Qcodes/qcodes/plots/base.py in add(self, updater, *args, **kwargs)
     68         self.expand_trace(args, kwargs)
     69         self.add_updater(updater, kwargs)
---> 70         self.add_to_plot(**kwargs)
     71 
     72     def add_to_plot(self, **kwargs):

/Users/Adriaan/GitHubRepos/DiCarloLab_Repositories/Qcodes/qcodes/plots/pyqtgraph_plot.py in add_to_plot(self, subplot, **kwargs)
    322 
    323         if 'name' in kwargs:
--> 324             subplot_object.setTitle('#{} - {}'.format(subplot+1, kwargs['name']))
    325 
    326         if 'clear' in kwargs:

AttributeError: 'Dock' object has no attribute 'setTitle'

@MerlinSmiles
Copy link
Contributor

maybe you need to update your pyqtgraph to get that setTitle functionality the version im running here is 0.9.10

@AdriaanRol
Copy link
Contributor Author

Just checked pip list tells me I am running pyqtgraph (0.9.10)

@MerlinSmiles
Copy link
Contributor

no clue why you get that error then. But its not really needed, so what is the error if you remove that line? :)

@AdriaanRol
Copy link
Contributor Author

Commented out lines 323 and 324 in Qcodes/qcodes/plots/pyqtgraph_plot.py.
Live updating plot works brilliantly :)

I'd say it works (and I also like how you can dump it to the notebook). Seems like this PR will solve this issue 👍

screenshot 2016-07-13 22 05 55

@MerlinSmiles
Copy link
Contributor

could you try to figure out why you dont have that setTitle ?

Maybe I should split that timing thing out into an individual PR then, it will take a little until i have the time to look at the other stuff I think schould be there. But that will then also not include the notebook dumping.

@nataliejpg
Copy link
Contributor

After live plotting working fine for both MatPlot and QtPlot it now doesn't work in my experiment and just waits to plot until the data.sync() has finished (I can't even update my plot manually in the meantime). Perhaps something to do with the fact that it's a 'hard' parameter but I don't really see why that would make a difference...

@MerlinSmiles
Copy link
Contributor

@nataliejpg I dont understand exactly. Does your plotting work with the above changes, or did you fix your system? I'll make the changes up there to a separate PR, so it can be added faster.

So live plotting works but not in your experiments? Are you running your loop in the background? Then the plotting calls the sync() and you don't need to.
Not sure what a 'hard' parameter is...

@alexcjohnson
Copy link
Contributor

There seems to be a regression so live plotting doesn't work right for array-valued parameters at all right now - @nataliejpg showed it to me with her VNA but I see it in the tutorial too. The issue is with bookkeeping on the DataServer, getting confused about what data it has in its arrays. Investigating...

@alexcjohnson alexcjohnson self-assigned this Jul 20, 2016
@MerlinSmiles
Copy link
Contributor

Ok, I see, missing context :D

@nataliejpg
Copy link
Contributor

Sorry, I thought the 'hard' parameter was discussed previously. It's my 'multidimensional parameter'.

@giulioungaretti
Copy link
Contributor

Closing. MP is deprecated. And eventually the new architecture will solve this things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants