def showSqFlucts(modes, *args, **kwargs): """Show square fluctuations using :func:`~matplotlib.pyplot.plot`. .. plot:: :context: :include-source: plt.figure(figsize=(6,4)) showSqFlucts( p38_anm[0] ) showSqFlucts( p38_anm[1] ) plt.legend(prop={'size': 10}) .. plot:: :context: :nofigs: plt.close('all')""" import matplotlib.pyplot as plt sqf = calcSqFlucts(modes) if not 'label' in kwargs: kwargs['label'] = str(modes) show = plt.plot(sqf, *args, **kwargs) plt.xlabel('Indices') plt.ylabel('Square fluctuations') plt.title(str(modes)) return show
def showScaledSqFlucts(modes, *args, **kwargs): """Show scaled square fluctuations using :func:`~matplotlib.pyplot.plot`. Modes or mode sets given as additional arguments will be scaled to have the same mean squared fluctuations as *modes*. .. plot:: :context: :include-source: plt.figure(figsize=(5,4)) showScaledSqFlucts(p38_pca[0], p38_anm[2]) plt.legend(prop={'size': 10}) .. plot:: :context: :nofigs: plt.close('all')""" import matplotlib.pyplot as plt sqf = calcSqFlucts(modes) mean = sqf.mean() args = list(args) modesarg = [] i = 0 while i < len(args): if isinstance(args[i], (VectorBase, ModeSet, NMA)): modesarg.append(args.pop(i)) else: i += 1 show = [plt.plot(sqf, *args, label=str(modes), **kwargs)] plt.xlabel('Indices') plt.ylabel('Square fluctuations') for modes in modesarg: sqf = calcSqFlucts(modes) scalar = mean / sqf.mean() show.append(plt.plot(sqf * scalar, *args, label='{0:s} (x{1:.2f})'.format(str(modes), scalar), **kwargs)) return show
def showNormedSqFlucts(modes, *args, **kwargs): """Show normalized square fluctuations using :func:`~matplotlib.pyplot. plot`. .. plot:: :context: :include-source: plt.figure(figsize=(5,4)) showNormedSqFlucts(p38_pca[0], p38_anm[2]) plt.legend(prop={'size': 10}) .. plot:: :context: :nofigs: plt.close('all')""" import matplotlib.pyplot as plt sqf = calcSqFlucts(modes) args = list(args) modesarg = [] i = 0 while i < len(args): if isinstance(args[i], (VectorBase, ModeSet, NMA)): modesarg.append(args.pop(i)) else: i += 1 show = [plt.plot(sqf/(sqf**2).sum()**0.5, *args, label='{0:s}'.format(str(modes)), **kwargs)] plt.xlabel('Indices') plt.ylabel('Square fluctuations') for modes in modesarg: sqf = calcSqFlucts(modes) show.append(plt.plot(sqf/(sqf**2).sum()**0.5, *args, label='{0:s}'.format(str(modes)), **kwargs)) return show