<p>我真的认为我可以用<code>seaborn.tsplot</code>来做。但看起来不太对劲。这是我和西伯恩的结果:</p>
<pre><code>cluster_overload = pd.read_csv("TSplot.csv", delim_whitespace=True)
cluster_overload['Unit'] = cluster_overload.groupby(['Cluster','Week']).cumcount()
ax = sns.tsplot(time='Week',value="Overload", condition="Cluster", ci=100, unit="Unit", data=cluster_overload)
</code></pre>
<p>输出:</p>
<p><a href="https://i.stack.imgur.com/5V2h7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5V2h7.png" alt="enter image description here"/></a></p>
<p>我真的很困惑为什么<code>unit</code>参数是必要的,因为我的理解是,所有的数据都是基于<code>(time, condition)</code>聚合的,而<a href="https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.tsplot.html" rel="nofollow noreferrer">Seaborn Documentation</a>将<code>unit</code>定义为</p>
<blockquote>
<p>Field in the data DataFrame identifying the sampling unit (e.g.
subject, neuron, etc.). The error representation will collapse over
units at each time/condition observation. This has no role when data
is an array.</p>
</blockquote>
<p>我不确定“崩溃”的含义,特别是因为我的定义不会将其作为必需的变量。</p>
<p>不管怎么说,如果你想得到你所讨论的内容,这里有一个输出,而不是几乎那么漂亮。我不知道如何在这些地区手动阴影,但请分享,如果你想出来。</p>
<pre><code>cluster_overload = pd.read_csv("TSplot.csv", delim_whitespace=True)
grouped = cluster_overload.groupby(['Cluster','Week'],as_index=False)
stats = grouped.agg(['min','mean','max']).unstack().T
stats.index = stats.index.droplevel(0)
colors = ['b','g','r']
ax = stats.loc['mean'].plot(color=colors, alpha=0.8, linewidth=3)
stats.loc['max'].plot(ax=ax,color=colors,legend=False, alpha=0.3)
stats.loc['min'].plot(ax=ax,color=colors,legend=False, alpha=0.3)
</code></pre>
<p>输出:<a href="https://i.stack.imgur.com/z2d8a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/z2d8a.png" alt="enter image description here"/></a></p>