[Python] How do I add an x=y line through this seaborn plot?

Discussão em 'Python' iniciado por Stack, Março 11, 2025.

  1. Stack

    Stack Membro Participativo

    I have a logarithmic scatter plot in seaborn, but I am wondering how to put an x=y line to bisect the data

    ax = sns.pairplot(x_vars=["Yamaguchi Double"], y_vars=["Yamaguchi Helix"], data=df11,
    hue="Image", size=3)
    ax.set(xscale="log", yscale="log", xlim=(1e-3,1e1), ylim=(1e-3,1e1))


    This produces this image:

    logarithmic plot

    How do I add a red diagonal x=y line over this?

    I've tried this code:

    ax = sns.pairplot(x_vars=["Yamaguchi Double"], y_vars=["Yamaguchi Helix"], data=df11,
    hue="Image", size=3)
    ax.set(xscale="log", yscale="log", xlim=(1e-3,1e1), ylim=(1e-3,1e1))
    X_plot = np.linspace(0.001, 10)
    Y_plot = X_plot
    plt.plot(x="X_plot", y="Y_plot", color = 'r')
    plt.show()


    but this gave me no line

    Continue reading...

Compartilhe esta Página