Matplotlib plot stops responding when trying to close it
0
0
Entering edit mode
2.8 years ago
Kevin ▴ 70

I am using a library called ProDy for protein analysis. One of the commands in this library creates a plot using matplotlib but when I try closing the plot it freezes and I need to force quit python.

The weird part is that the issue only happens when I try to do a loop to create multiple plots. If I just do one plot I can close it with no issues.

Singe plot code (works):

anm1 = ANM('f2000')
anm1.buildHessian(f2000)
anm1.calcModes()
anm2 = ANM('f1000')
anm2.buildHessian(f1000)
anm2.calcModes()
showOverlapTable(anm1[:], anm2[:]);
plt.show()

Loop code (produces first plot but freezes when trying to close that plot)

pdbs = [f2000, f1000, f1307, f1335]
pdbs_str = ['f2000', 'f1000', 'f1307', 'f1335']

pairs = [(a, b) for idx, a in enumerate(pdbs) for b in pdbs[idx + 1:]]
pairs_str = [(a, b) for idx, a in enumerate(pdbs_str) for b in pdbs_str[idx + 1:]]

# Visualize overlap tables for each pdb pair
for pair, pair_str in zip(pairs, pairs_str):
    anm1 = ANM(pair_str[0])
    anm1.buildHessian(pair[0])
    anm1.calcModes()
    anm2 = ANM(pair_str[1])
    anm2.buildHessian(pair[1])
    anm2.calcModes()
    showOverlapTable(anm1[:], anm2[:]);
    plt.show()
python python3 ProDy matplotlib • 1.0k views
ADD COMMENT
0
Entering edit mode

Not a perfect fix but using savefig() instead of showing the plot then saving it allows the loop to work.

ADD REPLY

Login before adding your answer.

Traffic: 1840 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6