Migrate from Bokeh Library to PyQtGraph or Vispy

987 views
Skip to first unread message

Chesu CR

unread,
May 5, 2021, 5:55:01 PM5/5/21
to pyqtgraph
Hello everybody,

I am considering migrating an app similar to the one in the link to PyQtGraph or Vispy. The App is built with the Bokeh library


Do you think that is possible? If you take a look at the gif in the main page of the project. I need to be able to interact with the samples in the graph by clicking on them. I also need to draw multiline plots on the samples graph, change some visibility of a group of samples, etc. I think you can get the whole idea just checking the gif.

Thanks in advance !!

Patrick

unread,
May 5, 2021, 11:19:59 PM5/5/21
to pyqtgraph
Hi,

What you describe is absolutely possible, but the "lasso" functionality shown in the gif would need to be custom written if you really wanted it. Selecting scatter points can be done (see the Graphics Items -> Scatter Plot example). I have done interacting with line plots and the show/hide checkbox thing for multiline plots before and it was reasonably straightforward. I can point you towards a code example of that if you need.

Patrick

Chesu CR

unread,
May 6, 2021, 8:41:43 AM5/6/21
to pyqtgraph
Thanks Patrick for the answer, a link to an example would be helpful.

All the plots that I have in the form of the application use the same data (similar to a matrix in pandas library). If one some sample is selected or some action or update is done, all the plots are updated. Besides, I can use different colors to different groups of samples. Can this be easily done as well?

I had several problems to do the app in Bokeh, and I don't know if I would have even more troubles in PyQtGraph with OpenGL. Does anyone know both libraries in order to compare functionalities?

Bokeh has a toolbar next to each plot that is quite useful, but if I use PyQtGraph I would have to create all those tools manually right?

Mikhail Terekhov

unread,
May 6, 2021, 10:21:34 AM5/6/21
to pyqt...@googlegroups.com
Just curious, what problems with Bokeh you are trying to solve?


Regards,

Mikhail

Ognyan Moore

unread,
May 6, 2021, 10:33:58 AM5/6/21
to pyqt...@googlegroups.com
Hi Chesu,

I'm Ogi, I'm one of the pyqtgraph maintainers.  I took a look at the gif in the README, PyQtGraph I think should be perfectly capable of doing the plots there, and likely getting the window/layout management as well.  Unfortunately due to the vast differences in frameworks that bokeh and pyqtgraph uses, there is likely little in the display portion of the code that can be re-used.

Generally speaking, I consider Bokeh to be a more mature library than pyqtgraph.  It has had corporate backing on/off since its inception, and Bryan, the main developer behind Bokeh is a very very skilled developer.  That said, I haven't used Bokeh enough to provide direct comparisons so it's hard for me to assess if pyqtgraph would be a better fit for you or not.

Regarding the toolbar of buttons, pyqtgraph does not have that by default; but I don't think the implementation would be that difficult with just creating your own button row Qt widget, and tying the signals/slots accordingly.  PyQtGraph rests a layer on top of the GraphicsView portion of the Qt framework, but it integrates into the entirety (minus the QML stuff) of the Qt framework with ease.  Given Qt's integration into the OS and its capabilities of handling all sorts of GUI components, replicating the toolbar functionality will probably be relatively straight forward.

This would likely be a fair amount of work, so unless there is some issue that Bokeh is unable to address; I would likely remain there.  That said, moving to the Qt framework has loads of advantages. 

--
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/b14ad8e1-9753-511d-01b4-80cec4d58d53%40gmail.com.

Chesu CR

unread,
May 6, 2021, 4:29:43 PM5/6/21
to pyqtgraph
Thanks for the detailed answer Ogi !!

Replying to Mike...

Actually I found some limitations with bokeh. As you can see in the gif, I need to have many plots displayed at the same time. Each plot has one multiline graph and one scatter graph, all the samples should be separated by colors. I had to limit the number of the multiline graph just to one or two profile lines (they are drawn only when some sample is selected), if not the app crashes. Even with these manual limitations, the app does not feel efficient like native. I know that JS has its limitations and the browser as well, but I was expecting that the interaction be more fluent.

Some developer recommended that I could have only rendered the plots in the current tab (the visible one), and then, when the user click on any other tab, the app could remove the plots of the old tab and load the new one. That could be a good improvement, however I think the result would be far from a native app.

Now I need to make a more powerful app with more files opened at the same time and the workflow should be much instant than that app. So that is why I was considering PyQtGraph and OpenGL

Ognyan Moore

unread,
May 6, 2021, 4:39:54 PM5/6/21
to pyqt...@googlegroups.com
Forgot to comment on the openGL bit.

While pyqtgraph supports it, there are a number of issues, including one nasty windows specific one (#1760) that have been elusive, and I don't think any of the active maintainers have much OpenGL experience to patch the issues, implement workarounds and so on.  I would advise turning on openGL only if default performance is not sufficient.

Pyqtgraph has no problems with many simultaneous plots, so unless you're looking at using some of the 3D functionality, I would suggest avoiding it.

The openGL implantation in VisPy is considered more robust (after all that's what their library is all about), but I suspect the effort level for making a VisPy application integrate into a desktop application may be higher.

PyQtGraph does have a scatter plot performance demo with tunable parameters that may give you a ballpark of what performance would be like.

Ballpark how many plots/scatter points are we talking here?

Patrick

unread,
May 7, 2021, 12:21:27 AM5/7/21
to pyqtgraph
Here's a screenshot from a project I'm currently working on. I've been working on the hardware and back end stuff recently, so the front end GUI hasn't been touched for a while. This is showing 10x 1.4 MB .csv data matrices loaded up. The three data panels are different views of the data and are all linked and updated in sync. The checkboxes toggle visibility of each data set, and mouse interaction works to select traces by clicking on the plot (highlighted in white). I have tried loading 100 or so matrices in and it still works fine, though the slowdown is noticeable.
Screenshot from 2021-05-07 13-33-32.png
Source code is public, specifically you'll want to look at this file for mouse interaction etc: datapanel.py

Chesu CR

unread,
May 7, 2021, 7:29:54 AM5/7/21
to pyqtgraph
Thanks Patrick for your example !! That's quite similar to what I need.

I am talking about:
  • Samples: over 1 million samples in every plot , where a scatter and a multiline graph could be shown at the same time. The matrix may have 50-100 columns. If the multiline graph does not need a different matrix structure, I would need just one big matrix for all the plots.
  • Plots: 100 for each file as maximum. I would need to open more than one file at the same time to make comparisons (they could be in the background temporarily if it's too much)
I know this can work fluent in Matlab, but I don't know if that's currently possible in Python
Reply all
Reply to author
Forward
0 new messages