Open
Description
Hello everyone,
I am looking to replicate a boxplot visualization using the Plotly Graph Card in Home Assistant, similar to what I've achieved using Matplotlib and Seaborn. Below is the code I used to generate the plot:
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
# Set random seed for reproducibility
np.random.seed(42)
# Define days of the week
days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
# Create varied capacity data for each day
capacity_means = {
'Monday': 45,
'Tuesday': 50,
'Wednesday': 55,
'Thursday': 60,
'Friday': 65,
'Saturday': 70,
'Sunday': 75
}
# Generate data
data = []
for day in days:
# Create a normal distribution for each day with different means
day_data = np.random.normal(loc=capacity_means[day], scale=10, size=150) # 150 samples per day
data.extend(zip([day]*150, day_data))
# Create a DataFrame
df = pd.DataFrame(data, columns=['Day', 'Capacity'])
# Plotting
plt.figure(figsize=(10, 6))
sns.boxplot(x='Day', y='Capacity', data=df, order=days, showmeans=False,
meanprops={"marker": "o", "markerfacecolor": "red", "markeredgecolor": "black", "markersize": "10"})
# Add labels and title
plt.title('Capacity Distribution by Day of the Week')
plt.xlabel('Day of the Week')
plt.ylabel('Capacity')
plt.legend()
# Show plot
plt.tight_layout()
plt.show()
Objective:
I want to display a similar boxplot in Home Assistant using the Plotly Graph Card. The plot should show:
- Each day of the week on the x-axis.
- Boxplots for each day with the capability to show mean/median and the 95th percentile.
Would this work with plotly graph card somehow?
Metadata
Metadata
Assignees
Labels
No labels