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)
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.
Scatter plots are used to show the relationship between two variables.
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.
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)
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