Box Plots
Box plots are useful for visualizing the distribution of a single numeric variable and identifying potential outliers. They are particularly effective for comparing the distribution of data across different categories or groups.
A box plot consists of a box, which encloses the first and third quartiles, and whiskers, which typically extend from the quartiles to the minimum and maximum values within 1.5 times the interquartile range. These components make box plots an excellent tool for summarizing data distributions clearly and concisely.
Tehtävä
Swipe to start coding
- Import the
seaborn
library with thesns
alias. - Import the
pyplot
module of thematplotlib
library with theplt
alias. - Generate three arrays with 100 observations each, with standard deviations (
std
) ranging from 1 to 4, exclusive. - Use the appropriate
seaborn
function to create a box plot. - Display the resulting plot.
Ratkaisu
# Import the seaborn library
import seaborn as sns
# Import the pyplot module
import matplotlib.pyplot as plt
import numpy as np
# Generate three arrays with different std
data = [np.random.normal(0, std, 100) for std in range(1, 4)]
# Creating a figure and axis
fig, ax = plt.subplots()
# Create a boxplot
sns.boxplot(data=data, ax=ax)
# Display the resulting plot
plt.show()
Mark tasks as Completed
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 1. Luku 2
AVAILABLE TO ULTIMATE ONLY