Open smoia opened 4 years ago
Update: it seems it's a problem related to the Qt4Agg
and Qt5Agg
backends in Spyder. Using the same backend from a python console (e.g. IPython) doesn't raise any issue. @rmarkello, which backend were you using when you were coding peakdet?
Oh jeez, that's a tough question... I was almost certainly using one of those you listed: likely originally Qt4Agg
and then later Qt5Agg
. I know that Spyder has a lot of confirmed graphical compatibility issues (e.g., I know it has bugs with the tqdm
module). Note that I have never used Spyder myself, so all development was done in Python/IPython, exclusively.
Ok, that's good to know! Out of curiosity, did you also test it in a jupyter notebook? Does it work without issues? I guess that then we can just add a warning in the documentation saying not to use it in Spyder...
@smoia : I tested it in a jupyter notebook yesterday! that's a funny coincidence. I was thinking of posting something here to cover the issue.
At first I thought it may be a %pylab inline
or %matplotlib inline
confusion, but then I realized the issue was too complex for me to describe properly. Here I am : it doesn't work in jupyter.
Mmm, like this it might be a bit difficult to "debug", but I'd say the first thing we can do is to write in the readme and in the documentation that we don't guarantee that the interactive plot session works in Spyder or Jupyter notebook. Sounds good?
Sounds right yeah. Pin me if you think you'd need me to send a PR
Sure! Why don't you go on and open a PR?
@sangfrois @smoia: you will likely need to install ipympl
and enable it with %matplotlib widget
for use of peakdet
in Jupyter notebooks! That is, loss of interactivity in maptlotlib plots is a standard feature of Jupyter notebooks and is not just peakdet
specific. (That's not to say peakdet
will 100% work with this solution, but it definitely won't work without it.)
(Also to explicitly answer @smoia's previous question: no, I had never tried testing in Jupyter!)
Ah, nice!
@sangfrois care to try it out? If it works we can add ipympl
as an extra dependency!
i think I've tried, but let me give it a shot again! I'll pin you once I'm done!
Ok, so : I've tried installing ipympl and executing %matplotlib widget
to get the interactive plot (using operation.edit_physio(data)
) and only got that string.
<matplotlib.axes._subplots.AxesSubplot at 0x1f3b07b9470>
Something seems to be processed here, so I've double checked with %matplotlib inline
and got a static figure.
Assuming that the string output meant there was a plot object, I've tried to call plt.show()
and got nothing 😢
Everything works fine in my terminal though. Even got the chance to try out the GUI. Looks great 😁
Here @smoia @rmarkello is there any other little tests you'd want me to try out?
New question: does the library need OpenGL?
@smoia: I'm not sure! I want to say no, probably not, but did very limited testing on this whole thing 😅 Sorry to not be of more help here.
Revisiting that issue: The interactive plot is working for me in jupyter notebook when I specified either %matplotlib widget
or %matplotlib ipympl
. I can delete and add peaks. However, the deleted/added peaks do not appear afterward in the history of the Physio object...
Did you try to close the widget with ctrl+q as per documentation?
Yes. It seems to close the plot since after doing ctrl+q I can't interact with it. However, if I delete some peaks, nor the peaks when I call peaks on the object nor the history are updated..
Update: it works when using %matplotlib qt
:
data.peaks
) and history So I would suggest to just add a note in the doc to make it clear
This happens in Spyder 4 (didn't test on previous Spyder versions), in Ubuntu 18.04 and latest winpython. If we can figure out why, it would be great - starting with trying to reproduce the problem in different environments @physiopy/all .