I want to add into my QT project a plot functionality. Since it is much simplier to create a plot in Python (Matplotlib, bokeh, etc.) I've decided to save some time. How to make QT(c++) and python understand each other?
Related
I am working on a project that need me to generate a real time line chart on a separate display.
I'm able to have the real time line chart working on my laptop now but I also want the separate display to show only the line chart (the chart window only), I do not want to make the display as the duplicate of my laptop screen. Is there a way for me to do send the chart through HDMI using Python? Is there any library/ function that would be helpful? If Python won't work, is there any other tool that could be helpful for my case?
Feel free to let me know if you have any question regarding this scenario, any help is appreciated. :)
You can generate a graph with matplotlib. Save it to a specific location with some name.
Then use PyGame/ Tkinter/ PyQt5 to make a "window" to display the image.
Then extend your display. The projector display will have the PyGame/PyQt "window" in full-screen.
I think this is pretty much what you want.
Let me describe the background first:
We have a python package that uses matplotib to create animations.
Currently, we use this package to create gifs, which we embed into our website.
In the future, the number of animations will increase, so that we are looking for a way to create these gifs only dynamically when a user wants to see a gif. Preferably, these animations will be created in the browser using the CPU of the user. I have seen that mpld3 can be used to create visualizations, however, animations are not supported and it is using our CPU.
This leads me to the question: Does someone know about a way to generate animations from matplotlib code in the browser preferably using the CPU of the user (not a must have)? Maybe is there a way of using jupyter notebooks for that?
Is there any way of getting interactive tooltips in a matplotlib plot? For instance, I wanted to get this scatter plot with hovering tooltips (http://mpld3.github.io/examples/scatter_tooltip.html) functionality in my python application, because they are really useful for visualizations. Unfortunately, I do not want to show this in a browser, but integrated in my own python application, is there any way to do this?
Matplotlib can only create static images and animations. If you want something interactive, then the only way you're going to achieve this is by using a module that outputs javascript. I would suggest reading about bokeh.
It is well developed and gaining a lot of traction in the python world as being a good option for creating interactive plots. Here's an example of bokeh's hovertool capability.
Unfortunately, I do not want to show this in a browser, but integrated in my own python application
I'm not sure what your "own python application" is but you're not going to have a fun time making an interactive plot outside of a browser. I would highly suggest going a webapp route using bokeh if interactivity is truly important to you.
I'd like to know if a matplotlib chart be interactive, ie when you right click on a graph bar, a context menu opens, then you click one of the menu items and change the value of y value or you drag the top edge of the bar with mouse and it becomes taller etc,
In other words, can a matplotlib chart act like a GUI?
yep, though I should warn you: matplotlib isn't the best choice for interactive tasks. Depends on your tasks you may face performance or UX issues..
Take a look at the Chaco. It was designed for the creation of complex interactive plots.
Yes.
Matplotlib is based on Tkinter, so you can do all sorts GUI related things with it. For an example of how you can embed matplotlib in a Tkinter GUI see here:
http://matplotlib.org/examples/user_interfaces/embedding_in_tk.html
Similarly for the functionality you are describing, you require plots that know when they've been clicked on (or mouse-overed) and that you can add callback events to. For that, the first place to look would be picker events:
http://matplotlib.org/examples/event_handling/pick_event_demo.html
As an alternative to some of the other ideas I would propose the Ipython notebook. For me it is the easiest way to do some of the things your asking about without having to get into Tkinter etc.
From Ipython 2.* onward there are interactive widgets allowing you to interact with the kernel from a GUI. I am not an expert in any sense so it is probably best explain by Fernando Perez himself.
Here is an example of interaction when solving the Lorenz differential equation demonstrating a chaotic system. This is accessible in the example of the ipython directory.
I want to visualize some measurement values in realtime. I think - although not finally sure - I can do this with PyChart. The surrounding application is based on PyQt.
Now I', wondering how I can put the chart drawn using PyChart into some qt widget, may be a QGraphicWidget?
Could someone give me a bit advise?
Cheers,
Wolfgang
I have learned to do this by following the instructions of Eli Benderski.
It is answered here on this site in this thread
Demo Code is here
This uses matplotlib instead of PyChart. Usage of matplotlib is well documented here.
Matplotlib allows you to interact with the plot canvas as well as importing a Navigation Tool Bar.
Hope this is helpful.