BarPlot Flashcards
What is the purpose of the estimator
parameter in a Seaborn barplot?
The estimator
parameter specifies the function used to aggregate data (default: mean
). Common options include sum
, median
, or len
.
How do you disable error bars in a Seaborn barplot?
Set ci=None
in the sns.barplot()
function to disable error bars.
What does the hue
parameter do in a barplot?
The hue
parameter adds subgroups to the categorical variable, splitting bars by a second categorical column (e.g., hue='sex'
).
How do you create a horizontal barplot?
Use orient='h'
and swap x
and y
variables (e.g., x='total_bill', y='day', orient='h'
).
How do you reorder categories in a barplot?
Use the order
parameter to specify category order (e.g., order=['Sun', 'Sat', 'Fri', 'Thur']
).
What is the default confidence interval (ci
) value?
The default is ci=95
, which calculates a 95% confidence interval for error bars.
How do you show standard deviation instead of confidence intervals?
Set ci='sd'
to display standard deviation as error bars.
How do you customize bar colors in a barplot?
Use the palette
parameter (e.g., palette='Blues_d'
) or color
for uniform colors.
How do you add annotations to bars?
Loop through ax.patches
and use ax.annotate()
to add text labels.
How do you visualize total values (sum) instead of averages?
Set estimator=sum
to aggregate data by summing values per category.