How to make a GUI using PyQt5 and Matplotlib to plot real-time data: PyQt5 tutorial - Part 10
HTML-код
- Опубликовано: 22 авг 2024
- Today in Python, we will design a simple but beneficial graphical user interface (GUI) with PyQt5. We will plot live audio data, that is sampled from computer's audio device. We will use the Matplotlib figure and update the canvas in the GUI according to the set interval. We will use pyqtSlot, QTimer, QThreadPool, sounddevice, and queue in this tutorial. This is part 10 of the PyQt5 learning series.
Source code: pyshine.com/Ho...
Music: www.bensound.com
IMPORTANT TUTORIAL LINKS
Transfer video over sockets from multiple clients: pyshine.com/So...
How to track Mario in Python: pyshine.com/tr...
What are yield and return statements in Python: pyshine.com/Di...
How to automatically arrange the desktop icons: pyshine.com/Ho...
How to plot realtime frame rate of a web camera: pyshine.com/Ho...
How to make screen recorder in PyQt5: pyshine.com/Ho...
How to make a real time voice plot: pyshine.com/Ho...
How to make a piano in Python: pyshine.com/Ho...
Making Python GUI for sine and cosine: pyshine.com/Ho...
Pandas dataframe with hexadecimal and ascii values: pyshine.com/Pa...
Socket programming to send and receive webcam video: pyshine.com/So...
Faster and accurate object tracking in Python: pyshine.com/Ob...
OpenCV and Real time streaming protocol (RTSP): pyshine.com/Re...
How to deploy Python video processing application on the server: pyshine.com/Ho...
How to publish-subscribe video using socket programming in Python: pyshine.com/Fa...
How to send audio from a client computer to a server over the wifi: pyshine.com/Se...
How to visualize Earthquakes in Python: pyshine.com/Ho...
How to stream video and bidirectional text in socket programming: pyshine.com/Vi...
How to send audio data using socket programming in Python: pyshine.com/Ho...
How to send audio and video using socket programming in Python: pyshine.com/Ho...
How to send video using UDP socket in Python: pyshine.com/Se...
How to easily stream picamera video over wifi with Raspberry Pi: pyshine.com/Ea...
How to configure Raspberry Pi in Ad hoc wifi mode: pyshine.com/Ho...
How to easily stream webcam video over wifi with Raspberry Pi: pyshine.com/Ea...
How to easily install OpenCv in Raspberry Pi boards: pyshine.com/Ho...
How to stream multiple videos on an HTML webpage:pyshine.com/Li...
This is, simply outstanding. I'm learning Python and just recently forayed into the front end with PyQt5 and designer. Every tutorial I've found online (well to be fair, nearly every) does the same things, "Hello World". Combining all of the functionality into this app, including matplotlib, numpy, audio processing, this is just the kind of tutorial I've been looking for. I get it, the standard in the programming world is start with "Hello World" and build on it. However, too many never go anywhere substantial. The sample apps they create show some simple signals/slots, use of graphical elements, etc... but never end up anywhere substantial. Thank you. I'm hooked. Subscribed and diving into the material on your channel and web site. Lastly, tying your code base into interfacing with hardware and the raspberry pi? That's my jam. I've got a Pi4 with 8GB ram, 64bit OS and 240GB SSD (booting from). I run my dev environment on this and it absolutely ROCKS! Way to out SHINE the rest and provide lessons that actually go somewhere!
You're welcome and glad its helpful
this is AWESOMEEEEEEEEEEEEEEEEE!!!!!!!!!!!!!!!!!!!!!!!, its the very very very best thing that i see in a long time, i really love this, i came here searching silver, and i found gold!!!
great tutorial. Thanks for posting. I will recommend to other learners.
thank you very much just what i wanted
Glad I could help
GREATTT!! Thanks a lot!!!
Thanks!!!
Hello Sir, how can we plot or scatter plot real-time CSV, txt data files?
Can you please help with it?
Hi, please follow this pyshine.com/How-to-plot-real-time-frame-rate-in-opencv-and-matplotlib/ and instead using plt.plot you can work around with plt.scatter
@@pyshine_official thank you so much, Sir! Good luck with your further works :)
Sample rate must be GREATER THAN twice the fundamental and should be much higher. (It takes a nearly infinite amount of time to resolve a signal if the sampling frequency is close to f/2.
Great development, It was very useful for what I wanted to do. I have a question: You define the function Update_plot with a While loop, but this function is called periodically by QtTimer, so if You quit the While loop is still works. Is the While loop necessary for something else or is just redundant? I cannot see any reason why we would want it. Thank you for your dedication!!!
Good question, the while can be avoided, simple replace the try except queue.Empty part with data=[0]
Really nice tutorial. I am trying to plot several page report with pyqt with alternating text and graphs with few push buttons. For example push button 1 will display some text for Milk sale per month with some matplotlib. I am finding it difficult to find a layout for such report. unfortunately i cant upload a sample pdf in comment section, so I am directly emailing you a sample pdf. Please share any idea how to generate such report.
Probably the closest one is this pyshine.com/Drag-Drop-CSV-File-on-PyQt5-GUI/ Saved your data to csv and use this tutorial for text you can add label under the graph. The text in that label will come from some test file or even from the same csv. For example you can add an extra column in csv that will contain the relevant text for each plot. Bind a bush button to load csv and display data and text
it looks great. EVERYBODY I NEED HELP. I have a task that wants me to make a progressbar which will be updating/refreshing every second with the values that I take from somewhere. lets say its a list. I created a loop for updating it and added a delay time with time.sleep but it didnt work. it takes all the delay time at once and after looking at a blank window for 10 seconds i get a display of a progressbar with the last value in the array. PLEASE HELP
This might be helpful focus on the progressbar pyshine.com/Play-Rock-Paper-Scissors-Game-using-PyQt5-GUI/
Any advise on how we can package this app to an exe?. From my experience packaging apps that make use of libraries such that matplotlib, numpy or pandas make huge executables that makes packaging essentially useless.
Yes the package might be large, use pyinstaller
Can we able to plot the graph without loading ui..i.e create the plot programatically
is it possible?
Yes we can plot pyshine.com/How-to-make-a-real-time-voice-plot/
how can add command prompt in qt5 Designer
Good question, it will be added on pyshine.com, stay tuned
Great work, pleas can I aske you some questions please ?
Hi great tutorials! I tried running the code but I keep getting:
'ValueError: Multiple input devices found for 'Microphone (NVIDIA Broadcast)':
[1] Microphone (NVIDIA Broadcast), MME
[27] Microphone (NVIDIA Broadcast), Windows DirectSound
[68] Microphone (NVIDIA Broadcast), Windows WASAPI
This unfortunately happens with every single audio device I try to use. MME, Windows DirectSound, and Windows WASAPI are always in the error message following the name of the audio device.
You have to use a simple 3.5 mm jack microphone, not a webcam.
How to make it possible to change the window and other parameters in real time, while is already playing?
Excellent question! Since functions are running under various threads with their own parameters. We can use seprate queue based variables to safely provide the parameter value a thread running a function. In that fuction the parameter value can be applied before the next time step.
I loved your video. I am still stuck tho, can you help me with something? I have a QWidget that has 2 tabs. Tab #1 handles data input and tab 2 plots it. I can not make it to work. I have my tab2 as a separate class but it's parent is tab1. I will say tho that main Data Strucutre (Dictionary) is outside my gui class.. do I need to put that inside? please help
I would really really appreciate it, I am at this issue more than a week now. As a beginner I find it very difficult
I completely copied your code, but Im getting this error:
QObject::killTimer: Timers cannot be stopped from another thread
QObject::startTimer: Timers cannot be started from another thread
QObject::setParent: Cannot set parent, new parent is in a different thread
Hi, Please use this for stopping pyshine.com/PyQt5-Live-Audio-GUI-with-Start-and-Stop/
@@pyshine_official 👍
It's amazing but can you tell me .......the details you show like sample rate , frequency are right...... please help ?
Yes, these are input parameters and works well as long as hardware allows
@@pyshine_official it's very confusing.....how can you make sample rate of 44100 hz from mic input
@@surendrathakur3479 Hi, the mic input is analog signal provided to an analog to digital converter of your sound device. The sample rate is given to sound device digitizer. By default most audio digitizers can sample sound at this rate
@@pyshine_official you are awesome and clearing all my doubt........does downsample drop every 10th sample of the sound by your program.......or can I change all the parameter written in gui....... please I beg to you help me out, the question may arise when I show it to my guide
How to run nmap im pyqt design
wow! how you did that?
Any thoughts how you could plot csv data coming that comes streaming from a serial port? Basically, get all the ascii up to the carriage-return/line-feed, then parse / plot each csv value, before getting the next line of data. Or do you think the processing would take too long and drop serial data?
Hi! serial port data can be plotted by each chunk, depending on the baud rate the stream of chunks can be appended to a csv file. And in a separated thread simple read that csv and plot. In that way the serial data will not drop and can be plotted.
@@pyshine_official thank you.. how can i do this with separate thread
i need help, to change the input using a arduino
Hi, please elaborate the format of data, is it serial or text based?
@@pyshine_official its serial data
can you explain how to change input based on serial plotter from arduino, please?