PDA

View Full Version : PyQt5 chart



ecce
23rd April 2016, 12:50
I would like a pretty simple bar chart in a PyQt application I'm making. I've been looking around a bit on how to create such charts, there seems to be a few solutions but none of them seems to me like a fairly simple and straight forward option. It does not have to be interactive. Any suggestions in which direction to go? This is what I've found:


Matplotlib. Not a native part of python, needs to be installed manually fot Qt5 support. I want to keep the code as easily manageable as possible (all GUI in QtDesigner, not in code, if possible) and I'm a bit afraid matplotlib will force me to do a bit of GUI coding manually. Also I want the application to be easily movable to other platforms (I'd prefer a big fat all-in-one exe file for windows, without "you need to install this and that first"-solution).
QtCharts. Does not seem to be natively supported by PyQt. Otherwise it looks really easy to use.
SVG.
Manual painting with QPaint. Feels a bit unnecessarily low-level.


Do you guys know any more options? Since I'm new on this it sure helps if good documentation exists.

d_stranz
23rd April 2016, 23:34
Matplotlib does seem to have a Python interface through pyplot (http://matplotlib.org/api/pyplot_summary.html#). I don't know where the plots are hosted though - whether in your own window or one of matplotlib's.

After more searching, here's an example of matplotlib embedded in a Qt5 widget (http://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html).

ecce
24th April 2016, 14:06
Matplotlib does seem to have a Python interface through pyplot (http://matplotlib.org/api/pyplot_summary.html#). I don't know where the plots are hosted though - whether in your own window or one of matplotlib's.

After more searching, here's an example of matplotlib embedded in a Qt5 widget (http://matplotlib.org/examples/user_interfaces/embedding_in_qt5.html).

I've looked a bit at that, there's also a nice gallery with code examples on their web site. I drawback is that you cannot simply apt-get install it, you need a newer version, meaning manual install, and that pretty much always means a lot more work than anyone will admit since Linux environments can be set up in so may ways. But I'll give it a try, cant find any better option right now.