Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in plot_cktest Function,Maybe the version of Matplotlib Compatibility #202

Open
yuqingxiong96 opened this issue Oct 23, 2024 · 0 comments

Comments

@yuqingxiong96
Copy link

I'm following the tutorial on your GitHub page, but I encountered an error when calling pyemma.plots.plot_cktest(). The error traceback indicates:
File "/mnt/WORKSPACE/xiongyq/AD/Tau/7p65_av1451/analyse/msm/test2.py", line 21, in
pyemma.plots.plot_cktest(msm.cktest(4), units='ps')
File "/home/xiongyq/WORKSPACE/soft/anaconda3/lib/python3.11/site-packages/pyemma/plots/markovtests.py", line 168, in plot_cktest
fig.legend(handles, labels, 'upper center', ncol=2, frameon=False)
File "/home/xiongyq/WORKSPACE/soft/anaconda3/lib/python3.11/site-packages/matplotlib/figure.py", line 1146, in legend
handles, labels, kwargs = mlegend._parse_legend_args(self.axes, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xiongyq/WORKSPACE/soft/anaconda3/lib/python3.11/site-packages/matplotlib/legend.py", line 1382, in _parse_legend_args
raise _api.nargs_error('legend', '0-2', len(args))

I suspect this may be related to my Matplotlib version (3.8.4).
Here’s the code I used:

import matplotlib.pyplot as plt
import numpy as np
import pyemma
import os

pdb = 'alanine-dipeptide-nowater.pdb'
files = sorted([f for f in os.listdir('.') if f.startswith('alanine-dipeptide-') and f.endswith('-250ns-nowater.xtc')])

feat = pyemma.coordinates.featurizer(pdb)
feat.add_backbone_torsions(periodic=False)
data = pyemma.coordinates.load(files, features=feat)
data_concatenated = np.concatenate(data)

cluster = pyemma.coordinates.cluster_kmeans(data, k=200, max_iter=50, stride=10)
msm = pyemma.msm.estimate_markov_model(cluster.dtrajs, lag=10, dt_traj='1 ps')
pyemma.plots.plot_cktest(msm.cktest(4), units='ps')
plt.savefig('ck_test_result.png', bbox_inches='tight')

Could this be an issue with the Matplotlib version? And how can I resolve this problem?
Thank you for your assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant