Bug bars with nautical and striped shades

I ran into some difficulties adding error bars to my sites that I created in Python using Seaborn.

I currently have a data frame in the 'csv' format,

TSMdatabase = 'TSMvsRunmaster.csv';
tsmdf = pd.read_csv(TSMdatabase, sep=',');

The Dataframe format has the following format:

Run,TSMX_Value,TSMX_Error,TSMX+1_Value,TSMX+1_Error,Source

Then I use the for loop to read in different TSM values:

TSM = ['001', '002', '003', '004', '010', '011', '012', 
   '013', '016', '017', '101', '102', '104', '105', '106']

for x in TSM:
     tsm = x

And then, finally, I give me the opportunity:

plt.figure()
sns.set_style("darkgrid")
ax = sns.stripplot(x="Run", y='TSM'+str(tsm)+'_Value', hue="Source", data=tsmdf, 
                   jitter=True, palette="Set2", split=True)
plt.xticks(rotation=40)
plt.title('Run TSM'+str(tsm)+' Comparison')
plt.show()

Plot for a specific TSM without errors Plot for certain TSM without Error Bars

If I try to add error bars, I get only one error panel in the middle of each data set:

enter image description here

where each source, Python and Matlab actually have their own errors in the data frame!

Does anyone have any ideas! Thank you very much!

+4
source share
1

+ sns.pointplot(), sns.stripplot(). Seaborn:

sns.pointplot , . .

sns.stripplot , . , , .

, + , , , :

import seaborn as sns
%matplotlib inline

tips = sns.load_dataset('tips')
sns.pointplot('sex', 'tip', hue='smoker',
    data=tips, dodge=True, join=False)

enter image description here

95% ci:

sns.pointplot('sex', 'tip', hue='smoker',
    data=tips, dodge=True, join=False, ci='sd')

enter image description here

. , , sns.pointplot() . , plt.errorbar() sns.pointplot():

ax = sns.pointplot('sex', 'tip', hue='smoker',
    data=tips, dodge=True, join=False, ci=None)

# Find the x,y coordinates for each point
x_coords = []
y_coords = []
for point_pair in ax.collections:
    for x, y in point_pair.get_offsets():
        x_coords.append(x)
        y_coords.append(y)

# Calculate the type of error to plot as the error bars
# Make sure the order is the same as the points were looped over
errors = tips.groupby(['smoker', 'sex']).std()['tip']
colors = ['steelblue']*2 + ['coral']*2
ax.errorbar(x_coords, y_coords, yerr=errors,
    ecolor=colors, fmt=' ', zorder=-1)

enter image description here

matplotlib , x-, .

-1

Source: https://habr.com/ru/post/1673779/


All Articles