I am using
How can I permanently resolve this issue in my development environment?
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# Read data from file, skipping the first row (header)
data = np.loadtxt('cm.dat', skiprows=1)
# Initialize reference point
x0, y0, z0 = data[0]
# Compute squared displacement for each time step
SD = [(x - x0)**2 + (y - y0)**2 + (z - z0)**2 for x, y, z in data]
# Compute the cumulative average of SD to get MSD at each time step
MSD = np.cumsum(SD) / np.arange(1, len(SD) + 1)
# Generate time steps
t = np.arange(1, len(SD) + 1)
# Create a log-log plot of MSD versus t
plt.figure(figsize=(8, 6))
plt.loglog(t, MSD, marker='o')
plt.title('Mean Squared Displacement vs Time')
plt.xlabel('Time step')
plt.ylabel('MSD')
plt.grid(True, which="both", ls="--")
plt.show()
C:\Users\pc\AppData\Local\Programs\Python\Python311\python.exe C:/git/RouseModel/tau_plot.py
C:\git\RouseModel\tau_plot.py:29: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Process finished with exit code 0
I have the same issue. In my case, I installed the PyQt5==5.15.10. After that, I run my code successfully.
pip install PyQt5==5.15.10
or pip install PyQt5
with python==3.11
But from 2024, you guys should install version PyQt6
or the last version with python==3.12
or later.