Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting single data point using seaborn

I am using seaborn to create a boxplot. But how would I add a line or a single point to show a single data value on the chart. For instance how would i go about plotting the value 3.5 on the below chart.

import seaborn as sns
import matplotlib.pyplot as plt

df1 = [2.5, 2.5, 2, 3, 4, 3.5]
sns.set_style("whitegrid")
fig, ax = plt.subplots(figsize=(8,8))
plot1 = sns.boxplot(ax=ax, x=df1, linewidth=5)
like image 651
ben121 Avatar asked Jan 26 '18 07:01

ben121


People also ask

Why Seaborn is used in Python?

Seaborn is a library for making statistical graphics in Python. It builds on top of matplotlib and integrates closely with pandas data structures. Seaborn helps you explore and understand your data.

Which of the following plots can be used to show the relationship between two quantitative variables 1 box plot 2 line plot 3 scatter plot 4 histogram?

Scatter plots are used to show the relationship between two variables.

When would you use a point plot?

Point plots can be more useful than bar plots for focusing comparisons between different levels of one or more categorical variables. They are particularly adept at showing interactions: how the relationship between levels of one categorical variable changes across levels of a second categorical variable.


1 Answers

You can achieve the same effect using plt.scatter. Personal preference, as the syntax is shorter and more succinct:

df1 = [2.5, 2.5, 2, 3, 4, 3.5]
sns.set_style("whitegrid")
fig, ax = plt.subplots(figsize=(8,8))
plot1 = sns.boxplot(ax=ax, x=df1, linewidth=5)

plt.scatter(3.5, 0, marker='o', s=100)
like image 76
sacuL Avatar answered Sep 24 '22 00:09

sacuL