Shivraj8615 commited on
Commit
d2bfb60
·
verified ·
1 Parent(s): 777c559

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -13
app.py CHANGED
@@ -3,9 +3,16 @@ import pandas as pd
3
  import seaborn as sns
4
  import matplotlib.pyplot as plt
5
  import numpy as np
 
 
 
 
 
 
 
6
 
7
  def main():
8
- st.title("Excel Column Analysis Dashboard")
9
 
10
  uploaded_file = st.file_uploader("Upload an Excel file", type=["xls", "xlsx"])
11
 
@@ -25,19 +32,23 @@ def main():
25
 
26
  st.write(f"**Calculated Standard Deviation:** {std_dev:.4f}")
27
 
28
- fig, axes = plt.subplots(1, 2, figsize=(12, 5))
29
-
30
- sns.histplot(data, kde=True, ax=axes[0], bins=20, color='blue')
31
- axes[0].set_title(f"Distribution Plot of {selected_column}")
32
-
33
- sns.lineplot(x=data.index, y=data, ax=axes[1], label='Data')
34
- axes[1].axhline(y=np.mean(data), color='r', linestyle='--', label='Mean')
35
- axes[1].axhline(y=np.mean(data) + std_dev, color='g', linestyle='--', label='+1 Std Dev')
36
- axes[1].axhline(y=np.mean(data) - std_dev, color='g', linestyle='--', label='-1 Std Dev')
37
- axes[1].legend()
38
- axes[1].set_title(f"Standard Deviation Plot of {selected_column}")
39
 
40
- st.pyplot(fig)
 
 
 
 
 
 
 
 
 
41
  else:
42
  st.warning("No numeric columns found in the uploaded file.")
43
 
 
3
  import seaborn as sns
4
  import matplotlib.pyplot as plt
5
  import numpy as np
6
+ import io
7
+
8
+ def save_plot(fig):
9
+ buf = io.BytesIO()
10
+ fig.savefig(buf, format="png")
11
+ buf.seek(0)
12
+ return buf
13
 
14
  def main():
15
+ st.title("Distribution Curve Plotting Dashboard")
16
 
17
  uploaded_file = st.file_uploader("Upload an Excel file", type=["xls", "xlsx"])
18
 
 
32
 
33
  st.write(f"**Calculated Standard Deviation:** {std_dev:.4f}")
34
 
35
+ # Distribution Plot
36
+ fig_dist, ax_dist = plt.subplots(figsize=(6, 5))
37
+ sns.histplot(data, kde=True, ax=ax_dist, bins=20, color='blue')
38
+ ax_dist.set_title(f"Distribution Plot of {selected_column}")
39
+ st.pyplot(fig_dist)
40
+ st.download_button("Download Distribution Plot", save_plot(fig_dist), file_name="distribution_plot.png", mime="image/png")
 
 
 
 
 
41
 
42
+ # Standard Deviation Plot
43
+ fig_std, ax_std = plt.subplots(figsize=(6, 5))
44
+ sns.lineplot(x=data.index, y=data, ax=ax_std, label='Data')
45
+ ax_std.axhline(y=np.mean(data), color='r', linestyle='--', label='Mean')
46
+ ax_std.axhline(y=np.mean(data) + std_dev, color='g', linestyle='--', label='+1 Std Dev')
47
+ ax_std.axhline(y=np.mean(data) - std_dev, color='g', linestyle='--', label='-1 Std Dev')
48
+ ax_std.legend()
49
+ ax_std.set_title(f"Standard Deviation Plot of {selected_column}")
50
+ st.pyplot(fig_std)
51
+ st.download_button("Download Standard Deviation Plot", save_plot(fig_std), file_name="std_dev_plot.png", mime="image/png")
52
  else:
53
  st.warning("No numeric columns found in the uploaded file.")
54