我正在使用用 python 编写的后处理绘图脚本,使用 python 3.7 和 OSX 10.14
该脚本可能没有优化,但当我使用外接显示器时它运行良好。当我尝试在我的 macbook pro 15" 显示器(2018 年)上运行它时,它会冻结并变得非常缓慢且无响应,除非我将图形尺寸设置得足够小。
我不知道原因,也没有找到任何解释浏览互联网。关于什么会导致这种行为以及如何解决它的任何线索?
这是我正在运行的脚本的“剪切”版本。
import numpy as np
import matplotlib
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle, Circle
import sys
def main(iter0,iterN,its,out_dir='output'):
it0 = int(iter0)
itN = int(iterN)
itstep = int(its)
a = list(range(it0,itN+1,itstep))
loaded_steps=len(a)
e = np.loadtxt(out_dir+'/energy_data_dynamics')
#... load many other files
plt.ion()
fig = plt.figure(figsize=(20, 20),facecolor="white") #THESE DIMENSIONS WORK FOR ANY EXTERNAL SCREEN
# fig = plt.figure(figsize=(10, 10),facecolor="white") #THESE DIMENSIONS WORK FOR MACBOOK SCREEN
it = 0
for index in range(0,loaded_steps):
plt.cla()
plt.axes().set_aspect('equal')
#... plot many other subplots
ax414=plt.subplot(414)
ax414.plot(e[it0+it,0], e[it0+it,2], marker="o", color="crimson", ms=15)
ax414.plot(e[it0:itN+1,0], e[it0:itN+1,2],'-r')
ax414.set_title("Energy")
plt.show()
plt.pause(0.0000000001)
it+=itstep
if index == loaded_steps-1:
input("Plot finished - Press [enter] to continue.")
if __name__ == '__main__':
matplotlib.use("TkAgg")
its = 1
out_dir = 'output'
if len(sys.argv)>=4:
its = sys.argv[3]
if len(sys.argv)>=5:
out_dir = sys.argv[4]
main(sys.argv[1],sys.argv[2],its,out_dir)