Issue
I am using
- Windows 10
- PyCharm 2021.3.3 Professional Edition
- python 3.11.5
- matplotlib 3.8.1
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
Solution
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
Answered By - Tran Minh Quan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.