ojp*_*ojp 4 python matplotlib python-3.x seaborn
我用下面的代码绘制了以下图。我想创建一条横跨所有分面图的水平红色虚线以突出显示 200 以上的所有点,但是当我运行此命令时
plt.axhline(200, ls='--', linewidth=3, color='red')
Run Code Online (Sandbox Code Playgroud)
我只得到最后一个情节中的线条。我猜我需要遍历所有的图,但我不知道该怎么做。谢谢您的帮助。
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)
Run Code Online (Sandbox Code Playgroud)
for ax in axes:
ax.axhline(200, ls='--', linewidth=3, color='red')
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5603 次 |
最近记录: |