Browse Source

pythonskripty

Tomas-Ranusa 2 weeks ago
commit
d6b950e99d
1 changed files with 89 additions and 0 deletions
  1. 89 0
      boxplot_distribution.py

+ 89 - 0
boxplot_distribution.py

@@ -0,0 +1,89 @@
+import matplotlib.pyplot as plt
+
+#======================================================
+# ==              SCRIPT PARAMETERS                  ==
+#======================================================
+
+# === Basic statistics from the table ===
+COL_DIAMETER      =   "Diameter [mm]"
+COL_VELOCITY      =   "Velocity [m/s]"
+
+STATS = {
+    COL_DIAMETER: {
+        "min": 0.160,
+        "q1": 0.250,
+        "median": 0.310,
+        "q3": 0.410,
+        "max": 4.740
+    },
+    COL_VELOCITY: {
+        "min": 0.210,
+        "q1": 1.340,
+        "median": 1.670,
+        "q3": 2.020,
+        "max": 10.090
+    }
+}
+
+# === Figure Parameters ===
+FIG_WIDTH          =   6
+FIG_HEIGHT         =   4
+
+FIG_TITLE          =   "Distribúcia Priemerov a Rýchlostí Častíc Počas 41. týžna 2025"
+
+FIG_DATA_ALPHA     =    0.6
+
+FIG_SUB1_TITLE     =   "Priemer Častice [mm]"
+FIG_SUB1_X_LABEL   =   "Priemer [mm]"
+
+FIG_SUB2_TITLE     =   "Rýchlosť Častice [m/s]"
+FIG_SUB2_X_LABEL   =   "Rýchlosť [m/s]"
+
+
+FIG_DATA_COLOR1    =   "#4C72B0"
+FIG_DATA_COLOR2    =   "#DD8452"
+
+FIG_GRID_STYLE    =   ":"
+
+#======================================================
+# ==                SCRIPT COMMANDS                  ==
+#======================================================
+
+# === Prepare data for boxplot ===
+def make_box_dict(s):
+    return {
+        'whislo': s['min'],     # Bottom whisker
+        'q1': s['q1'],          # 25%
+        'med': s['median'],     # 50%
+        'q3': s['q3'],          # 75%
+        'whishi': s['max'],     # Top whisker
+        'fliers': []
+    }
+
+data_diam = [make_box_dict(STATS[COL_DIAMETER])]
+data_vel = [make_box_dict(STATS[COL_VELOCITY])]
+
+# === Plot side by side with independent y-scales ===
+fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(FIG_WIDTH, FIG_HEIGHT))
+
+# Diameter boxplot
+ax1.bxp(data_diam, showfliers=False, patch_artist=True,
+        boxprops=dict(facecolor=FIG_DATA_COLOR1, alpha=FIG_DATA_ALPHA))
+ax1.set_title(FIG_SUB1_TITLE)
+ax1.set_ylabel(FIG_SUB1_X_LABEL)
+ax1.set_xlabel("")
+ax1.set_xticks([])
+ax1.grid(True, linestyle=FIG_GRID_STYLE)
+
+# Velocity boxplot
+ax2.bxp(data_vel, showfliers=False, patch_artist=True,
+        boxprops=dict(facecolor=FIG_DATA_COLOR2, alpha=FIG_DATA_ALPHA))
+ax2.set_title(FIG_SUB2_TITLE)
+ax2.set_ylabel(FIG_SUB2_X_LABEL)
+ax2.set_xlabel("")
+ax2.set_xticks([])
+ax2.grid(True, linestyle=FIG_GRID_STYLE)
+
+plt.suptitle(FIG_TITLE)
+plt.tight_layout()
+plt.show()