Skip to content Skip to sidebar Skip to footer

Query On Errorbar() Added To Stripplot

I've been struggling to get desired errorbars for my categorical variable (x=Type) with two distinct marker shapes (per categories A and B) and errorbar colors matching the color o

Solution 1:

Unfortunately, seaborn is very difficult to work with if you are trying to move away from the plots that are offered.

In your case, I think it would be much easier to forgo seaborn altogether and to generate a plot using standard matplotlib functions:

markers = ['s','o']
colors = ['k', 'r']
grouped = df.groupby('Type')

fig, ax = plt.subplots()
for i,((g,d),m,c) inenumerate(zip(grouped,markers,colors)):
    # generate scattered x values, adjust scale= as needed
    x = np.random.normal(loc=i,scale=0.05,size=(len(d['Y'],))) 
    ax.errorbar(x,d['Y'],yerr=d['Err'],
                fmt=m, color=c, capsize=3)
ax.set_xticks(list(range(len(grouped))))
ax.set_xticklabels([a for a in grouped.groups])

enter image description here

Post a Comment for "Query On Errorbar() Added To Stripplot"