def plot_sequence(seqID, Data, dimID=0, maxT=200):
Xseq = Data.X[Data.doc_range[seqID]:Data.doc_range[seqID + 1]]
Zseq = Data.TrueParams['Z'][
Data.doc_range[seqID]:Data.doc_range[
seqID +
1]]
Xseq = Xseq[:maxT, dimID] # Xseq is 1D after this statement!
Zseq = Zseq[:maxT]
# Plot X, colored by segments Z
changePts = np.flatnonzero(np.abs(np.diff(Zseq)))
changePts = np.hstack([0, changePts + 1])
for ii, loc in enumerate(changePts[:-1]):
nextloc = changePts[ii + 1]
ts = np.arange(loc, nextloc)
xseg = Xseq[loc:nextloc]
kseg = int(Zseq[loc])
color = GaussViz.Colors[kseg % len(GaussViz.Colors)]
pylab.plot(ts, xseg, '.-', color=color, markersize=8)
pylab.plot(
[nextloc - 1, nextloc], [Xseq[nextloc - 1], Xseq[nextloc]], 'k:')
pylab.ylim([-2, 14])
评论列表
文章目录