我正在使用
如何在我的开发环境中永久解决此问题?
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
我也有同样的问题。就我而言,我安装了 PyQt5==5.15.10。之后,我成功运行了我的代码。
pip install PyQt5==5.15.10
或 pip install PyQt5