msmbuilder / msmexplorer

Data visualizations for biomolecular dynamics
http://msmbuilder.org/msmexplorer/
MIT License
17 stars 17 forks source link

Wrong color in most dense region of free energy plot #91

Closed jeiros closed 7 years ago

jeiros commented 7 years ago

Hi,

I'm running into a weird issue with plot_free_energy and I can't think of why it's happening.

I load some trajectories using a dataset from msmbuilder, featurize and scale them. The tICA time series look normal:

pipeline = Pipeline([
    ('feat', AtomPairsFeaturizer(atom_pairs)),
    ('scale', RobustScaler()),
    ('tica', tICA(n_components=3, lag_time=100)),
    ('cluster', MiniBatchKMeans(n_clusters=500)),
    ('msm', MarkovStateModel(lag_time=100, n_timescales=5))
])
scaled_data = pipeline.named_steps['scale'].fit_transform(pipeline.named_steps['feat'].fit_transform(xyz))
tica_trajs = pipeline.named_steps['tica'].fit_transform(scaled_data)

ax, side_ax = msme.plot_trace(np.concatenate(tica_trajs)[:, 0],
                              label='tIC1', xlabel='Timestep', color='rawdenim')
_ = msme.plot_trace(np.concatenate(tica_trajs)[:, 1],  label='tIC2',
                    xlabel='Timestep', color='cochineal', ax=ax,
                    side_ax=side_ax)

tica_trace But the free energy plot colors the most dense region with the same colour as where there are no data points:

msme.plot_free_energy(np.concatenate(tica_trajs),
                      obs=(0, 1), pi=None,
                      shade=True,
                      n_levels=5,
                      cmap='Spectral',
                      clabel=True,
                      clabel_kwargs={'fmt': '%.1f'},
                      xlabel='tIC1', ylabel='tIC2'
)

free_energy_plot

I've tried using other color maps and changin the n_levels argument, but I still get the white region in the center. Have you seen this before / have any idea of why this might be happening?

cxhernandez commented 7 years ago

Try vmin=-1e-12 or a very small (in absolute value) negative number. Maybe this should be set as the default.

jeiros commented 7 years ago

Thanks, that did the trick!