在facetplot上绘制水平线(季节性重绘)

问题描述 投票:0回答:1

我用下面的代码绘制了以下图表。我想创建一条横跨所有构面的水平红色虚线,以突出显示200以上的所有点,但是当我运行此时>

plt.axhline(200, ls='--', linewidth=3, color='red')

我只在最后一个情节中得到这条线。我猜我需要遍历所有情节,但是我不确定该怎么做。感谢您的帮助。

enter image description here

g = sns.relplot(x='hour', y="n",
                 col="w_day", hue="Zone",
                 kind="scatter", ci=95, data=df_1, col_order=col_order)

axes = g.axes.flatten()
axes[0].set_title("Monday")
axes[1].set_title("Tuesday")
axes[2].set_title("Wednesday")
axes[3].set_title("Thursday")
axes[4].set_title("Friday")
axes[5].set_title("Saturday")
axes[6].set_title("Sunday")

axes[0].set_ylabel("Hourly N")
for ax in axes:
    ax.set_xlabel("Hour")

g.fig.suptitle('', 
               weight='semibold', 
               y= 1.06, 
               size='x-large')

plt.axhline(200, ls='--', linewidth=3, color='red')


plt.margins(x=0)
plt.subplots_adjust(hspace=0, wspace=0)

我用下面的代码绘制了以下图表。我想创建一条横跨所有构面的水平红色虚线,以突出显示所有高于200的点,但是当我运行此plt时。...

python python-3.x matplotlib seaborn
1个回答
0
投票
for ax in axes:
    ax.axhline(200, ls='--', linewidth=3, color='red')
© www.soinside.com 2019 - 2024. All rights reserved.