Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create pirate plot in seaborn (combination of box and point plot)

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

like image 563
Georg Heiler Avatar asked Jul 28 '17 05:07

Georg Heiler


People also ask

How do I create a boxplot in Seaborn?

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

How to create a strip plot in Seaborn using Python?

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.

How do I break the data out by date in Seaborn?

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.

How to use whisker length in Seaborn boxplots in Python?

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.


1 Answers

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.

enter image description here

like image 160
error Avatar answered Sep 30 '22 11:09

error