tsplot 的颜色底图
Color underplot of tsplot
我想在 Seaborn 中为 tsplot
的下半部分着色。我有以下代码:
sns.tsplot(time=time,data=data)
是否可以为图的下方区域着色?我尝试使用 barplot
,但我的数据太大,所以它看起来不正确。有什么建议吗?
尝试使用 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()
我想在 Seaborn 中为 tsplot
的下半部分着色。我有以下代码:
sns.tsplot(time=time,data=data)
是否可以为图的下方区域着色?我尝试使用 barplot
,但我的数据太大,所以它看起来不正确。有什么建议吗?
尝试使用 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()