def _plot_stateseq_data_values(self,s,ax,state_colors,plot_slice,update):
from matplotlib.collections import LineCollection
from pyhsmm.util.general import AR_striding, rle
data = s.data[plot_slice]
stateseq = s.stateseq[plot_slice]
colorseq = np.tile(np.array([state_colors[state] for state in stateseq[:-1]]),data.shape[1])
if update and hasattr(s,'_data_lc'):
s._data_lc.set_array(colorseq)
else:
ts = np.arange(len(stateseq))
segments = np.vstack(
[AR_striding(np.hstack((ts[:,None], scalarseq[:,None])),1).reshape(-1,2,2)
for scalarseq in data.T])
lc = s._data_lc = LineCollection(segments)
lc.set_array(colorseq)
lc.set_linewidth(0.5)
ax.add_collection(lc)
return s._data_lc
评论列表
文章目录