HITS-MBM / conan

Analysis of contacts in molecular dynamics trajectories
https://hits-mbm.github.io/conan/
GNU General Public License v3.0
41 stars 13 forks source link

Non interactive backend for matplotlib #4

Open ijpulidos opened 4 years ago

ijpulidos commented 4 years ago

Hello. From what I've seen the matplotlib backend when running CONAN is left as the default for the system. Lately I've run into some issues that I wasn't running into before. They are detailed here: https://gist.github.com/ijpulidos/dc4b96f0be7c114b00d4eb5723c4b0be

As far as I can see, changing some lines in how matplotlib is imported fixes this issue, basically I did the following in the header of the conan.py file:

import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

As suggested in https://matplotlib.org/faq/howto_faq.html#working-with-threads and referenced in https://stackoverflow.com/questions/4706451/how-to-save-a-figure-remotely-with-pylab/4706614#4706614 . I think it would also improve the ability to run conan in parallel using threads or similar. I'm just not sure if this would end up having issues with other things or features from Conan, since I really haven't tested it extensively.

ijpulidos commented 4 years ago

Ok, apparently the issue in the gist in my previous comment is related to matplotlib version. I run into it with an old matplotlib 2.2.2 but not with 3.2.2. So that's one thing. I still think there could be some benefits on using the "Agg" backend, though, specially in terms of thread safety.

csabadaday commented 4 years ago

?Hi Iván,

interesting. I only use matplotlib for cluster analysis (where the dendrogram is plotted), so I did not spend a lot of time optimising those plots. I'll check out your suggestion though.

Thanks!

Best

Csaba

Dr. Csaba Daday Postdoc Molecular Biomechanics

HITS gGmbH Schloss-Wolfsbrunnenweg 35 69118 Heidelberg Germany

phone +49 6221 533 311 fax +49 6221 533 298 email: csaba.daday@h-its.org http://www.h-its.orghttp://www.h-its.org/


Amtsgericht Mannheim / HRB 337446 Managing Director: Dr. Gesa Schönberger Scientific Director: PD Dr. Wolfgang Müller


From: Iván Pulido notifications@github.com Sent: Tuesday, June 23, 2020 9:27 PM To: HITS-MBM/conan Cc: Subscribed Subject: Re: [HITS-MBM/conan] Non interactive backend for matplotlib (#4)

Ok, apparently the issue i the gist in my previous comment is related to matplotlib version. I run into it with an old matplotlib 2.2.2 but not with 3.2.2. So that's one thing. I still think there could be some benefits on using the "Agg" backend, though, specially in terms of thread safety.

- You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/HITS-MBM/conan/issues/4#issuecomment-648371135, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHEXHOUI7QU3AQIUJ6NR4STRYD625ANCNFSM4OF54G3Q.

cdboschen commented 4 years ago

I want to also report the issue I found with trying to use the interactive plots in Jupyter Notebooks immediately after installing the most recent Anaconda (2020.07) on a Windows 10 platform. The issue specifically was that only the upper left hand quartile of a plot would display and can be reproduced in a notebook by doing:

import matplotlib.pyplot as plt

%matplotlib notebook
# running the above in its own code cell

plt.figure()
plt.plot([1,5],[2,10])    #or any other plot

I was able to reproduce this in a minimum environment of only installing the latest versions of python (3.8.5), jupyter (1.0.0) and matplotlib (3,3,0).

After rolling back to matplotlib version 3.1.3 in the minimum environment and then in the complete Anaconda 2020.07 installation the issue was resolved for me.