FigureCanvasAgg interactivity problem

Hello, I recently reinstalled VSCode on my windows machine, and even when using identical code with the exact same matplotlib install it was throwing errors at me. The code was just a test script i wrote to try and see where the problem might be but I didn’t really get anywhere:

import matplotlib.pyplot as plt
import numpy as np

xpoints = np.random.randint(250, size=100)
ypoints = np.random.randint(250, size=100)

colour = (xpoints/xpoints.max())*50+(ypoints/ypoints.max())*50

plt.ion()
plt.plot([0,100],[100,0])
plt.scatter(xpoints, ypoints, c = colour, cmap = ‘viridis’)
plt.show()

The error it then threw at me was:

C:\Users*Username*\Documents\VSCode\test.py:12: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()

I had the same warning on Ubuntu 22.04. Installing pyqt5 worked for me.

python -m pip install PyQt5

Hope this helps

4 Likes

Did not work for me, I have the same error

It’s worked!! Thanks! I had this warning on windows vscode.

Future Person™ here - installing PyQt6 worked for me. Thanks!

1 Like