Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

boxplot python count of data

import matplotlib.pyplot as plt
import seaborn as sns
df = sns.load_dataset("iris")
ax = sns.boxplot(y="species", x="sepal_length", data=df) 
medians = df.groupby(['species'])['sepal_length'].median().values
nobs = df['species'].value_counts().values
nobs = [str(x) for x in nobs.tolist()]
nobs = ["n: " + i for i in nobs] 
pos = range(len(nobs))
for tick,label in zip(pos,ax.get_yticklabels()):
    ax.text(medians[tick],tick,nobs[tick],color='black', verticalalignment = "bottom")
sns.despine()
plt.show();
Comment

PREVIOUS NEXT
Code Example
Python :: Constructing a Class with __init__ function 
Python :: jpg image in tkinter title 
Python :: how to rename columns using panda object 
Python :: unpacking of tuples in python 
Python :: what exception occurs when you convert a atring to an integer and fail in python 
Python :: plot line2d on axis 
Python :: successful=true for number in range (3) print ("Attempt") if successful: print ("Successful") breal 
Python :: how to send variable to python using xlwings 
Python :: Issue TypeError: ‘numpy.float64’ object cannot be interpreted as an integer 
Python :: Kinesis Client get_records example 
Python :: ;dslaoeidksamclsoeld,cmskadi934lglllfgl;llgldklkkkkjkklllloooofklllflll;=f]p[ 
Python :: how to make an infinite loop in python 
Python :: how to see if something is in a class in python 
Python :: anagram game 
Python :: flask lazy response style with `make_response` 
Python :: label default text value python 
Python :: what if init migrations run two times or by pass this migrate 
Python :: iris data pandas scatterplot 
Python :: python use orange 
Python :: check if a date is reached django 
Python :: uneven chunks of array slices 
Python :: set environment variable heroku django 
Python :: unction which takes in a list of integers and returns a dictionary of the five number summary.. 
Python :: sns regplot make the line and confidence interval thicker 
Python :: ternary operator using dictionary in Python 
Python :: How to get values in each cluster 
Python :: python send commands in one line but write in multiple 
Python :: Creating sub elements in xml in python with ElementTree 
Python :: how to reverse a number 
Python :: python index 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =