【问题标题】:How can we plot a vertical line on all subplots using Python seaborn relplot?我们如何使用 Python seaborn relplot 在所有子图上绘制一条垂直线?
【发布时间】:2019-04-21 02:34:51
【问题描述】:

用于创建绘图的 Python 代码如下。这将创建基于"variable" 的子图:

s=sb.relplot(x="timestamp",y="value",hue="variable",row="variable",
kind="line",facet_kws=dict(sharey=False),height=0.8, aspect=7,data=e)

plt.axvline(flip_timex)

s.fig.autofmt_xdate()

plt.show()

我需要在生成的所有子图上添加一条垂直线(在固定日期)。

plt.axvline(flip_timex) 仅在一个子图上添加一条垂直线。

【问题讨论】:

    标签: python seaborn


    【解决方案1】:

    您需要在所有生成的图中创建线。

    grid = seaborn.relplot(...)
    for ax in grid.axes.flat:
        ax.axvline(...)
    

    【讨论】:

    • 在我的示例中,我必须循环稍有不同,作为补充:fig, axs = pl.subplots(ncols=2)sns.kdeplot(..., ax=axs[0])sns.kdeplot(..., ax=axs[1])for ax in fig.axes:ax.axvline(...)
    猜你喜欢
    • 2019-02-02
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    相关资源
    最近更新 更多