基于这个难以置信的答案,我能够创建一个猴子补丁来精美地完成您想要的工作。
import pandas as pdimport seaborn as sns import seaborn.timeseriesdef _plot_range_band(*args, central_data=None, ci=None, data=None, **kwargs): upper = data.max(axis=0) lower = data.min(axis=0) #import pdb; pdb.set_trace() ci = np.asarray((lower, upper)) kwargs.update({"central_data": central_data, "ci": ci, "data": data}) seaborn.timeseries._plot_ci_band(*args, **kwargs)seaborn.timeseries._plot_range_band = _plot_range_bandcluster_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", unit="Unit", data=cluster_overload, err_, n_boot=0)
输出图:
如果您知道为什么
unit需要该变量,请告诉我。
如果您不希望它们全部都在同一图形上,则:
import pandas as pdimport seaborn as snsimport seaborn.timeseriesdef _plot_range_band(*args, central_data=None, ci=None, data=None, **kwargs): upper = data.max(axis=0) lower = data.min(axis=0) #import pdb; pdb.set_trace() ci = np.asarray((lower, upper)) kwargs.update({"central_data": central_data, "ci": ci, "data": data}) seaborn.timeseries._plot_ci_band(*args, **kwargs)seaborn.timeseries._plot_range_band = _plot_range_bandcluster_overload = pd.read_csv("TSplot.csv", delim_whitespace=True)cluster_overload['subindex'] = cluster_overload.groupby(['Cluster','Week']).cumcount()def customPlot(*args,**kwargs): df = kwargs.pop('data') pivoted = df.pivot(index='subindex', columns='Week', values='Overload') ax = sns.tsplot(pivoted.values, err_, n_boot=0, color=kwargs['color'])g = sns.FacetGrid(cluster_overload, row="Cluster", sharey=False, hue='Cluster', aspect=3)g = g.map_dataframe(customPlot, 'Week', 'Overload','subindex')
产生以下内容(如果认为比例不正确,显然可以使用宽高比)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)