How to Show Mean on Boxplot using Seaborn in Python?
The mean is generally added to boxplots as a point inside of the box with a line going over it. Alternatively, the yellow shaded area can be replaced by another line or symbol. For analysis purposes, it helps to be able to add these lines and symbols to an existing boxplot in Seaborn.
show avg value in sns boxplot
By Thankful Tiger
on May 23, 2020
import seaborn as sns
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
box_plot = sns.boxplot(x="day",y="total_bill",data=tips)
medians = tips.groupby(['day'])['total_bill'].median()
vertical_offset = tips['total_bill'].median() * 0.05 # offset from median for display
for xtick in box_plot.get_xticks():
box_plot.text(xtick,medians[xtick] + vertical_offset,medians[xtick],
horizontalalignment='center',size='x-small',color='w',weight='semibold')
Source: stackoverflow.com
0
It would also make sense to give that option its own spot in the list_plot function rather than forcing people to go about it in varying ways.
Python answers related to "show avg value in sns boxplot"
show avg value in sns boxplot python seaborn boxplot python avg heatmap sns python seaborn boxplot Seaborn boxplot multiple columns Seaborn boxplot multiple columns view all columns in pandas dataframe pandas see all columns list conda environments django admin image heatmap sns
View All Python queries
Python queries related to "show avg value in sns boxplot"
show avg value in sns boxplot python avg heatmap sns Seaborn boxplot multiple columns python seaborn boxplot index of max value of sequence python fill np array with same value how to check if value is in list python value count in python for key value in dict python python dictionary get value find whether one tuple value is available in another tuple sort defaultdict by value Input contains NaN, infinity or a value too large for dtype('float64'). python count value in list plot value counts pandas how to value counts of two columns in pandas
Browse Other Code Languages
Abap ActionScript Assembly BASIC C C# C++ Clojure Cobol CSS Dart Delphi Elixir Erlang F# Fortran Go Groovy Haskell Html Java Javascript Julia Kotlin Lisp Lua Matlab Objective-C Pascal Perl PHP PostScript Prolog Python R Ruby Rust Scala Scheme Shell/Bash Smalltalk SQL Swift TypeScript VBA WebAssembly Whatever