Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
|
|
2 |
import numpy as np
|
3 |
import pandas as pd
|
4 |
import matplotlib.pyplot as plt
|
5 |
-
from scipy.stats import norm
|
6 |
from io import BytesIO
|
7 |
|
8 |
st.title("KPI Std. Deviation")
|
@@ -58,16 +57,26 @@ if max_val > mean_val > min_val:
|
|
58 |
|
59 |
df = pd.DataFrame({
|
60 |
f"{kpi_selected} Value ({unit})": x,
|
61 |
-
|
62 |
})
|
63 |
|
64 |
# Plot
|
65 |
fig, ax = plt.subplots()
|
66 |
-
ax.plot(x, y, color='royalblue', linewidth=2)
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
ax.set_xlabel(f"{kpi_selected} ({unit})")
|
69 |
ax.set_ylabel("Probability Density")
|
70 |
-
ax.grid(True, which='both', linestyle='--', linewidth=0.5, alpha=0.7)
|
71 |
st.pyplot(fig)
|
72 |
|
73 |
# Download data as CSV
|
@@ -89,4 +98,4 @@ if max_val > mean_val > min_val:
|
|
89 |
mime="image/png"
|
90 |
)
|
91 |
else:
|
92 |
-
st.warning("Please ensure that: Min < Mean < Max to generate a valid bell curve.")
|
|
|
2 |
import numpy as np
|
3 |
import pandas as pd
|
4 |
import matplotlib.pyplot as plt
|
|
|
5 |
from io import BytesIO
|
6 |
|
7 |
st.title("KPI Std. Deviation")
|
|
|
57 |
|
58 |
df = pd.DataFrame({
|
59 |
f"{kpi_selected} Value ({unit})": x,
|
60 |
+
"Probability Density": y
|
61 |
})
|
62 |
|
63 |
# Plot
|
64 |
fig, ax = plt.subplots()
|
65 |
+
ax.plot(x, y, color='royalblue', linewidth=2, label='Deviation Curve')
|
66 |
+
|
67 |
+
# Markers for Min, Mean, Max
|
68 |
+
ax.axvline(min_val, color='blue', linestyle='--', linewidth=1)
|
69 |
+
ax.axvline(mean_val, color='green', linestyle='--', linewidth=1)
|
70 |
+
ax.axvline(max_val, color='red', linestyle='--', linewidth=1)
|
71 |
+
|
72 |
+
ax.text(min_val, max_pdf * 0.1, f'Min\n{min_val} {unit}', color='blue', ha='center')
|
73 |
+
ax.text(mean_val, mean_pdf + 0.05, f'Mean\n{mean_val} {unit}', color='green', ha='center')
|
74 |
+
ax.text(max_val, max_pdf * 0.1, f'Max\n{max_val} {unit}', color='red', ha='center')
|
75 |
+
|
76 |
+
ax.set_title(f"{kpi_selected} - Std. Deviation Curve")
|
77 |
ax.set_xlabel(f"{kpi_selected} ({unit})")
|
78 |
ax.set_ylabel("Probability Density")
|
79 |
+
ax.grid(True, which='both', linestyle='--', linewidth=0.5, alpha=0.7)
|
80 |
st.pyplot(fig)
|
81 |
|
82 |
# Download data as CSV
|
|
|
98 |
mime="image/png"
|
99 |
)
|
100 |
else:
|
101 |
+
st.warning("Please ensure that: Min < Mean < Max to generate a valid bell curve.")
|