Problem after click Monitor: FigureCanvasAgg is non-interactive, and thus cannot be shown plt.show()
Hi, I got problem after click Monitor and the monitor task stops. Could you help me to figure it out? ^_^
Here's the error message:
C:\Users\82056.platformio\penv\Lib\site-packages\arduplot\plotserialdata.py:192: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
C:\Users\82056.platformio\penv\Lib\site-packages\matplotlib\animation.py:872: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. anim, that exists until you output the Animation using plt.show() or anim.save().
warnings.warn(
- The terminal process "C:\Users\82056.platformio\penv\Scripts\platformio.exe 'device', 'monitor', '--environment', 'HID'" terminated with exit code: 2.
Could you describe more for me to understand the problem like below?
the environment the procedure to get this error any other information that may help understand the problem
Environment:
OS: Windows_NT x64 10.0.19045 (Windows 10 64bit) VS Code version: 1.96.0 (system setup) PlatformIO IDE: Core 6.1.16, Home 3.4.4 OS's Python: Python 3.12.7 PlatformIO IDE's Python: Python 3.11.7
Procedure to get this error
Just follow your instructions
Other information
The output of pip install arduplot in Terminal of PlatformIO:
$ pip install arduplot
Requirement already satisfied: arduplot in c:\users\82056\.platformio\penv\lib\site-packages (0.3.1)
Requirement already satisfied: matplotlib in c:\users\82056\.platformio\penv\lib\site-packages (from arduplot) (3.9.3)
Requirement already satisfied: pyserial in c:\users\82056\.platformio\penv\lib\site-packages (from arduplot) (3.5)
Requirement already satisfied: click in c:\users\82056\.platformio\penv\lib\site-packages (from arduplot) (8.1.7)
Requirement already satisfied: colorama in c:\users\82056\.platformio\penv\lib\site-packages (from click->arduplot) (0.4.6)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (1.3.1)
Requirement already satisfied: cycler>=0.10 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (4.55.3)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (1.4.7)
Requirement already satisfied: numpy>=1.23 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (2.2.0)
Requirement already satisfied: packaging>=20.0 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (24.1)
Requirement already satisfied: pillow>=8 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (11.0.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (3.2.0)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\82056\.platformio\penv\lib\site-packages (from matplotlib->arduplot) (2.9.0.post0)
Requirement already satisfied: six>=1.5 in c:\users\82056\.platformio\penv\lib\site-packages (from python-dateutil>=2.7->matplotlib->arduplot) (1.17.0)
The path of filter_plotter.py is a bit different from your doc. It's "C:\Users\82056.platformio\penv\Lib\site-packages\arduplot\filter_plotter.py"
Thank you for the information. What I would like to have are
how you run the arduplot?
- arduplot command
- pio device monitor command
- platformio.ini setup
And I would like to see the data coming out on the serial port as well.
With monitor/filter_plotter.py inside my project folder:
First try: Add monitor_filters = plotter in platformio.ini and then click the Monitor button of PlatformIO IDE.
Second try: No monitor_filters = plotter in platformio.ini and then run pio device monitor -f plotter
They get same result, and the data coming out on the serial port is (same as the error message I started this issue):
C:\Users\82056.platformio\penv\Lib\site-packages\arduplot\plotserialdata.py:192: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
C:\Users\82056.platformio\penv\Lib\site-packages\matplotlib\animation.py:872: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. anim, that exists until you output the Animation using plt.show() or anim.save().
warnings.warn(
I made a video with run pio device monitor -f plotter:
https://github.com/user-attachments/assets/054f3c62-3c23-4dba-8b9f-37c1f2e43349
Thank you for the video. That helps a lot.
The Arduino's Serial Plotter needs only numeric data, separated by white spaces in between if more than one. And the arduplot is made compatible with the Arduino's Serial Plotter.
So you need to remove any non measurement numeric data from the serial output.
ie)
23.5 70
23.2 71
22.4 69
But when I see your serial output, it has some other thing as below.
So modify the arduino code to print out this way.
12.300000 5.670000
23.400000 6.780000
12.300000 5.670000
Sorry for not reading about your print format. Several plot extensions of VS Code and Arduino IDE support this format ">VarName1:value1, VarName2:value2, ...", I thought it is standard. (Note: the leading '>' is only used for plotting flag in some VS Code extensions). However, when I modified my C/C++ code to print like your format, terminal got same result. Then I found you are using Python as the example. So, does this arduplot support other programming language?
As long as the data conforms, the programming language doesn't matter.
When you follow the README.md, you will find a github repo with a sample arduino project that is basically C/C++. Would you bulid and run this for the arduplot and compare with your code?
I tried the project, and it got same error.
I see. Then I suspect there is some incompatible version of prereqs.
Without access to your environment, it is hard to help you further.
I tested it from a new environment, but it still got the same error. Here's my steps:
- Installed a new Windows 10 x64 in VMware Workstation Pro 17.6.2.
- Installed a VS Code. No Python of OS is installed.
- Created a new Profile of VS Code, with default setting, only PlatformIO IDE and C/C++ extensions enabled.
- In PlatformIO Terminal, installed arduplot with
pip install arduplot. - Modified the code of 'iotlab101/pio_filter_dht22' to get rid of hardware dependence (dht22), then put "\monitor\filter_plotter.py" into project folder
- In PlatformIO Terminal, run
pio device monitorto check normal print. It was OK. - In PlatformIO Terminal, run
pio device monitor -f plotterto check arduplot. Got the error.
This is my test fork of the 'iotlab101/pio_filter_dht22': https://github.com/CharlesLiaoO/arduplot_pio_filter_dht22.git
I appreciate your interest in the arduplot and would really like to help.
Since you said it's a new VM, it may not have any sensitive data. If that's the case, then would you install a zoom client on it and could we setup a schedule a zoom session so I can take a look at your environment?
OK. I am free from Dec. 25 to Dec. 28 (only after 3pm on Dec. 27), Beijing Time. You could pick up a time and generate an invite link for me.
Great. Maybe we can have a zoom some time after 3pm on Dec 27 your time. I'll confirm shortly.
Meanwhile, would you run this program and see if you get the sine wave animation?
#!/usr/bin/env python3
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
# Create a figure and axis
fig, ax = plt.subplots()
ax.set_xlim(0, 2 * np.pi) # x-axis range
ax.set_ylim(-1.5, 1.5) # y-axis range
# Initialize a line object
x = np.linspace(0, 2 * np.pi, 100)
line, = ax.plot([], [], lw=2)
# Sine wave animation function
def animate(frame):
y = np.sin(x + 0.1 * frame) # Update sine wave phase
line.set_data(x, y) # Update line data
return line,
# Initialize function (optional, can leave empty)
def init():
line.set_data([], [])
return line,
# Create the animation
ani = FuncAnimation(
fig, animate, init_func=init, frames=200, interval=50, blit=True
)
# Display the animation
plt.title("Sine Wave Animation")
plt.show()
In system terminal, the python code can run and plot. In PlatformIO terminal, the python code got the error (same as the first part of above errors):
C:\Users\lch-vm-win10en\Desktop\NewFolder\t.py:34: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown plt.show()
So, I guess this issue is about the 'built-in' python environment in PlatformIO terminal/CLI.
By google, I guess it is about the plot library such as 'tkinter', but it seems not easy to solve for me (a ref: https://stackoverflow.com/questions/76105218/why-does-tkinter-or-turtle-seem-to-be-missing-or-broken-shouldnt-it-be-part
). And I tried to set platformio-ide.useBuiltinPython to false, but PlatformIO terminal still use the build-in python.
If there is still a need for Zoom meeting, this is the invite link:
Charles Liao is inviting you to a scheduled Zoom meeting.
Topic: Charles Liao's Zoom Meeting Time: Dec 27, 2024 03:00 PM Beijing, Shanghai Join Zoom Meeting https://us05web.zoom.us/j/82723950204?pwd=w4SfvQwkWgXdUmNG9QxxC8mVcSdeOY.1
Meeting ID: 827 2395 0204 Passcode: 6kx10K
If the test code is not running well in the PIO python environment but working fine on your system python venv, then the PIO python venv has some conflicting libraries. For this I guess we don't need the zoom meeting, rather you may need a help from PIO experts.