Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to display text on boxplot in python

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')
Comment

PREVIOUS NEXT
Code Example
Python :: pygame do you need to use int() for positions 
Python :: pyqt5 messagebox settext 
Python :: python xlrd date 
Python :: plt.plot(x, softmax(scores).T, linewidth=2) 
Python :: python print functoin 
Python :: odd number list generator 
Python :: online python text editor 
Python :: custom dense layer 
Python :: extract a subpart of a matrix 
Python :: python pass statement 
Python :: Python Creating a Tuple 
Python :: python reverse list every 2 element 
Python :: adding new character in string python 
Python :: ascci value pyth 
Python :: how to make a timer in pyothn 
Python :: python pynput hotkeys 
Python :: accessing a specific slide using python 
Python :: Python RegEx re.compile() Set class [s,.] will match any whitespace character ‘,’ or ‘.’ 
Python :: BMI CALCULATOR CODE IN PYTHON 
Python :: ValueError: y_true and y_pred contain different number of classes 6, 2. Please provide the true labels explicitly through the labels argument. Classes found in y_true: [0 1 2 3 4 5] 
Python :: flask how to initialze extension after start 
Python :: contigent def 
Python :: base64 encode image in python 
Python :: wn.synset vs wn.synsets in nltk 
Python :: 1045 - Triangle Types 
Python :: How to Use the abs() Function with a Complex Number Argument 
Python :: 5.2.5: Counting 10 to 100 by ... 
Python :: python arcade sound 
Python :: how to get foregine key field from models 
Python :: np.linalg.eigvals positive check python 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =