[Python] Colors in errorbar and seaborn scatterplot not matching

Discussão em 'Python' iniciado por Stack, Janeiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to add some x and y error on top of seaborn scatterplot. I am not able to find anywhere a solution to match the color between the two. I would be happy also with the marker being on top of the error lines and not the other way around.

    Is there anyone who could help me?

    Many thanks.

    Here's the code:

    plt.figure(figsize=(7, 5), dpi=200)
    sns.set_style("ticks")

    sns.scatterplot(y="D47 CDES (Final)", x="D48 CDES (Final)", data=data, palette="muted",
    hue="ID", style="ID", s=80)
    plt.errorbar(y="D47 CDES (Final)", x="D48 CDES (Final)", xerr="D48 CDES (Final) CI",
    yerr="D47 CDES (Final) CI", elinewidth=0.5,data=data, label=None, capsize=2, capthick=0.5)

    plt.tick_params(axis='x')
    plt.legend(loc='upper left', scatteryoffsets=[0.55], frameon=False, fontsize=9, ncol=3)
    plt.xlabel("$\Delta_{48}$", fontsize=15)
    plt.ylabel("$\Delta_{47}$", fontsize=15)

    plt.xlim(0,0.5)
    plt.ylim(0.45,0.7)
    plt.savefig("a.jpg", bbox_inches = 'tight')


    Here's the result: [​IMG]

    Continue reading...

Compartilhe esta Página