海洋线图表明活动趋势
在Seaborn
线路图上,我想指出时间序列数据的趋势,最好使用不同的颜色。
例如,获取此假数据:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame(np.random.randint(100, size=50), columns=['max'])
df['day'] = pd.date_range('2016-1-1', periods=50, freq='SMS')#freq='W')
df['date'] = df['day'].dt.strftime('%Y-%m')
在linePlot
上,这会产生以下图:
sns.lineplot(data=df, x = df['date'], y='max', )
plt.xticks(rotation=45)
所以我想指出2017-01之间的时间序列趋势
和2017-08
,以使该图的背景为绿色,并标记为“开始”和“类似于下图,但在指示的区域中插入绿色背景)。
On a seaborn
lineplot, I would like to indicate trend in a time-series data, preferably using different colours.
For example, taking this fake data:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.DataFrame(np.random.randint(100, size=50), columns=['max'])
df['day'] = pd.date_range('2016-1-1', periods=50, freq='SMS')#freq='W')
df['date'] = df['day'].dt.strftime('%Y-%m')
On a lineplot
this produces the following figure:
sns.lineplot(data=df, x = df['date'], y='max', )
plt.xticks(rotation=45)
So I would like to indicate the trend in time series between 2017-01
and 2017-08
such that the plot's background in this area is in green, with begin and end marked (similar to the figure below, but inserting green background in the area indicated).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
您可以使用 >:
输出:
与不同的
zorder
:output:
You can use
ax.axvspan
:output:
alternative with a different
zorder
:output: