tsplot的颜色下划线

时间:2016-06-25 02:57:46

标签: python matplotlib seaborn

我想在Seaborn中为tsplot的下半部分着色。我有以下代码:

sns.tsplot(time=time,data=data)

是否可以为地块的下部区域着色?我尝试使用barplot,但我的数据太大,所以看起来不对。有什么建议吗?

1 个答案:

答案 0 :(得分:1)

尝试使用matplotlib中的fill_between,例如:

import numpy as np; np.random.seed(22)
import seaborn as sns; sns.set(color_codes=True)
import matplotlib.pylab as plt
x = np.arange(31)
data = np.sin(x) + np.random.rand(10, 31) + np.random.randn(10, 1)
sns.tsplot(data=data)
ax = plt.gca()
ax.fill_between(x, np.sin(x), ax.get_ylim()[0], color='r')
plt.show()

enter image description here