Reputation: 137
I am trying to visualize some data using seaborns. I am using a catplot that is set to be a bar plot. I have it showing the error bars to be the standard deviation. I want to know what value it is using for the mean and standard deviation it is using in the visualization, however I do not know how to retrieve that information from the plot. How would I go about getting that information?
bar_graph = seaborn.catplot(x="x", y="y", hue="z", data=data, ci="sd", capsize=0.1, kind="bar")
Upvotes: 0
Views: 2459
Reputation: 40697
Trying to get that data from the plot generated by seaborn would not be impossible, but would be very cumbersome, as seaborn does not return the artists that it creates and catplot()
can generate a number of subplots, etc.
However, I expect you don't need to get the data from the plot, you can get them directly from the dataframe, can't you? This simple demonstration shows that the plot and the calculated values do match:
titanic = sns.load_dataset("titanic")
sns.catplot(x='sex',y='age',hue="class", data=titanic, ci="sd", capsize=0.1, kind="bar")
titanic.groupby(['sex','class'])['age'].describe()[['mean','std']]
mean std
sex class
female First 34.611765 13.612052
Second 28.722973 12.872702
Third 21.750000 12.729964
male First 41.281386 15.139570
Second 30.740707 14.793894
Third 26.507589 12.159514
Upvotes: 1