There exists a nice plot in R called pirate plot. It is a combination of box plot and point plot. How can I plot something similar in python with seaborn? You can find an example here: http://rpubs.com/yarrr/pirateplot
Seaborn has an aptly named sns.boxplot () function that is used to create, well, boxplots. To demonstrate the sns.boxplot () function, let’s import the libraries we’ll need as well as load a sample dataframe that comes bundled with Seaborn: import pandas as pd import seaborn as sns
For this seaborn is equipped with stripplot () function, all we have to do is call it just after boxplot () function with appropriate parameters to generate a boxplot with data points. A strip plot is drawn on its own.
Let’s start by creating a boxplot that breaks the data out by date on the x-axis and shows the total bill on the y-axis. Let’s see how we’d do this in Python: sns.boxplot(data=df, x='day', y='total_bill') plt.show() This returns the following image: Styling a Seaborn boxplot. The default boxplot generated by Seaborn is not the prettiest.
Let’s see how we can do this in Python: By default, Seaborn boxplots will use a whisker length of 1.5. What this means, is that values that sit outside of 1.5 times the interquartile range (in either a positive or negative direction) from the lower and upper bounds of the box.
This is the closest I can think of being like the pirateplot. Using both seaborn boxplot
and stripplot
.
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.boxplot(x="day", y="total_bill", data=tips)
ax = sns.stripplot(x="day", y="total_bill", data=tips, color=".25")
Resulting in this graph.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With