Member-only story
Univariate Charts
Hello,
1. Histogram
A histogram is used to represent the frequency distribution of a continuous variable.
import matplotlib.pyplot as plt
import numpy as np# Generate random data
data = np.random.randn(1000)# Plot histogram
plt.figure(figsize=(8, 6))
plt.hist(data, bins=30, color='blue', alpha=0.7)
plt.title('Histogram')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.show()2. Box Plot
A box plot (or box-and-whisker plot) shows the distribution of a dataset based on five summary statistics: minimum, first quartile (Q1), median, third quartile (Q3), and maximum.
import seaborn as sns# Generate random data
data = np.random.randn(1000)# Plot boxplot
plt.figure(figsize=(8, 6))
sns.boxplot(data=data, color='lightblue')
plt.title('Box Plot')
plt.xlabel('Value')
plt.show()3. Violin Plot
A violin plot is similar to a box plot, but it also shows the density of the data at different values.
# Plot violin plot
plt.figure(figsize=(8, 6))
sns.violinplot(data=data, color='lightgreen')
plt.title('Violin Plot')
plt.xlabel('Value')
plt.show()






