Histograms with Seaborn

import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Generate random data
data = np.random.randn(1000)

# Create a histogram
sns.histplot(data)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Generate random data
data = np.random.randn(1000)

# Create a histogram with a KDE
sns.histplot(data, kde=True)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Generate random data
data = np.random.randn(1000)

# Create a histogram with a specific number of bins
sns.histplot(data, bins=100)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Generate random data
data = np.random.randn(1000)

# Create a histogram
sns.histplot(data)

# Add a title and labels
plt.title('Histogram of Random Data')
plt.xlabel('Value')
plt.ylabel('Frequency')

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Generate random data
data = np.random.randn(1000)

# Create a histogram with a specific color
sns.histplot(data, color='purple')

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# Create a DataFrame with random data
df = pd.DataFrame({
    'A': np.random.randn(1000),
    'B': np.random.randn(1000)
})

# Create a histogram for column 'A'
sns.histplot(df['A'])

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create a histogram with labels and legend
sns.histplot(data['total_bill'], kde=True, color='skyblue')
plt.title('Distribution of Total Bill')
plt.xlabel('Total Bill')
plt.ylabel('Frequency')
plt.legend(['Total Bill'])

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create histograms for different subsets
sns.histplot(data[data['sex'] == 'Male']['total_bill'], color='blue', label='Male', kde=True)
sns.histplot(data[data['sex'] == 'Female']['total_bill'], color='pink', label='Female', kde=True)

# Add labels and legend
plt.title('Total Bill Distribution by Gender')
plt.xlabel('Total Bill')
plt.ylabel('Frequency')
plt.legend()

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('titanic')

# Create a histogram for a discrete dataset
sns.histplot(data['pclass'], discrete=True)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create a cumulative histogram
sns.histplot(data['total_bill'], cumulative=True)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create a histogram with a logarithmic x-axis
sns.histplot(data['total_bill'], log_scale=(True, False))

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create a multivariate histogram with hue
sns.histplot(data=data, x='total_bill', hue='time', element='step', stat='density', common_norm=False)

# Add labels and title
plt.title('Total Bill Distribution by Time of Day')
plt.xlabel('Total Bill')
plt.ylabel('Density')

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('tips')

# Create a jointplot
sns.jointplot(data=data, x='total_bill', y='tip', kind='hist', marginal_kws=dict(bins=30, fill=True))

# Add a title
plt.suptitle('Joint Distribution of Total Bill and Tip', y=1.02)

# Show the plot
plt.show()
import seaborn as sns
import matplotlib.pyplot as plt

# Load a sample dataset
data = sns.load_dataset('iris')

# Create a pairplot
sns.pairplot(data=data, hue='species', diag_kind='hist')

# Show the plot
plt.show()