/usr/share/pyshared/statsmodels/graphics/tsaplots.py is in python-statsmodels 0.4.2-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | """Correlation plot functions."""
import numpy as np
from . import utils
#copied/moved from sandbox/tsa/example_arma.py
def plotacf(corr, ax=None, lags=None, use_vlines=True, **kwargs):
""" Plot the auto or cross correlation.
Plots lags on the horizontal and the correlations on vertical axis.
Parameters
----------
corr : array_like
Array of correlation values, used on the vertical axis.
ax : Matplotlib AxesSubplot instance, optional
If given, this subplot is used to plot in instead of a new figure being
created.
lags : array_like, optional
Array of lag values, used on horizontal axis.
If not given, ``lags=np.arange(len(corr))`` is used.
use_vlines : bool, optional
If True, vertical lines and markers are plotted.
If False, only markers are plotted. The default marker is 'o'; it can
be overridden with a ``marker`` kwarg.
**kwargs : kwargs, optional
Optional keyword arguments that are directly passed on to the
Matplotlib ``plot`` and ``axhline`` functions.
Returns
-------
fig : Matplotlib figure instance
If `ax` is None, the created figure. Otherwise the figure to which
`ax` is connected.
See Also
--------
matplotlib.pyplot.xcorr
matplotlib.pyplot.acorr
mpl_examples/pylab_examples/xcorr_demo.py
Notes
-----
Adapted from matplotlib's `xcorr`.
Data are plotted as ``plot(lags, corr, **kwargs)``
"""
fig, ax = utils.create_mpl_ax(ax)
corr = np.asarray(corr)
if lags is None:
lags = np.arange(len(corr))
else:
if len(lags) != len(corr):
raise ValueError('lags and corr must be of equal length')
if use_vlines:
ax.vlines(lags, [0], corr, **kwargs)
ax.axhline(**kwargs)
kwargs.setdefault('marker', 'o')
kwargs.setdefault('linestyle', 'None')
ax.plot(lags, corr, **kwargs)
return fig
|