我预计最长为7-8年(在注册研究中收集的总时间数据)。在
创建间隔的快速可视化将最大间隔膨胀到100+年。在
我发布了我的代码和以下输出:有人看到我处理日期的问题了吗。
基本上,我取总范围和主题间隔,然后把它转换成天。在
def timeplot(dt):
# -- get time length
dt = dt.reset_index()
pd.to_datetime( dt['realtime'] )
#print dt.dtypes #print( dt.head(1) )
grpt = dt.groupby('subject_id')['realtime']
# -- timestamps min, max
subj_min = grpt.min() ; subj_max = grpt.max() ;descr = grpt.describe()
# -- time range to ints
# no. of days between (int)
mn = subj_max - subj_min
intdy = mn.map(lambda x: int(x.days))
#intsj = subj_min.map(lambda x: int(x.days))
#print('#deltaT', mn)
#print('days ', mn.map(type) )
print('day as int**: ', intdy )
# -- y is number of subjects,
y = xrange( dt.subject_id.nunique() )
# -- x is days int
mmin = dt.realtime.min()
mmax = dt.realtime.max()
mlen = mmax - mmin;
totdys = int(mlen.days)
# [mmin .. (min .. x1/2 .. max) .. mmax]
subrange = subj_min - mmin
subrdays = subrange.map(lambda x: int(x.days) )
#print('##! ', len(subrdays), subrdays[:10])
x5 = subrdays + intdy/2
print( '## ', totdys, len(y), len(x5) )
# plot
fig, ax = plt.subplots()
ax.errorbar( x5, y, xerr=(intdy*10), fmt='ok', ecolor='grey',elinewidth=50, alpha=0.9)
ax.set_xlabel("days");ax.set_ylabel("subjects")
由于某些原因,错误条也是垂直的(估计这只是一个缩放问题…) 我想让我的情节看起来更像下面的那个。在
**er,准确无所谓,只需寻找相对顺序、间距和长度进行视觉启发。作为一个快速破解,x轴是否可以被覆盖(标记为年)?我试着把它调成垂直的。。。在
目前没有回答
相关问题 更多 >
编程相关推荐