Sathwikchowdary commited on
Commit
5492c3f
·
verified ·
1 Parent(s): 6dfba44

Update pages/1player_information.py

Browse files
Files changed (1) hide show
  1. pages/1player_information.py +60 -2
pages/1player_information.py CHANGED
@@ -28,7 +28,7 @@ if selected_player:
28
 
29
  if show_batting:
30
  st.subheader(f"Batting Stats for {selected_player}")
31
-
32
  col1, col2 = st.columns(2)
33
  with col1:
34
  # Pie Chart - Matches Played
@@ -42,7 +42,7 @@ if selected_player:
42
  ax.pie(matches, labels=labels, autopct="%1.1f%%", startangle=90)
43
  ax.set_title(f"Matches Played by {selected_player}")
44
  st.pyplot(fig)
45
-
46
  with col2:
47
  # Bar Chart - Runs Scored
48
  batting_runs = [
@@ -57,6 +57,64 @@ if selected_player:
57
  ax.set_title(f"Runs Scored by {selected_player}")
58
  st.pyplot(fig)
59
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  if show_bowling:
61
  st.subheader(f"Bowling Stats for {selected_player}")
62
 
 
28
 
29
  if show_batting:
30
  st.subheader(f"Batting Stats for {selected_player}")
31
+
32
  col1, col2 = st.columns(2)
33
  with col1:
34
  # Pie Chart - Matches Played
 
42
  ax.pie(matches, labels=labels, autopct="%1.1f%%", startangle=90)
43
  ax.set_title(f"Matches Played by {selected_player}")
44
  st.pyplot(fig)
45
+
46
  with col2:
47
  # Bar Chart - Runs Scored
48
  batting_runs = [
 
57
  ax.set_title(f"Runs Scored by {selected_player}")
58
  st.pyplot(fig)
59
 
60
+ col3, col4 = st.columns(2)
61
+ with col3:
62
+ # Stacked Bar Chart - 100s and 50s
63
+ hundreds = [
64
+ player_data.get("batting_100s_Test", 0),
65
+ player_data.get("batting_100s_ODI", 0),
66
+ player_data.get("batting_100s_T20", 0),
67
+ player_data.get("batting_100s_IPL", 0)
68
+ ]
69
+ fifties = [
70
+ player_data.get("batting_50s_Test", 0),
71
+ player_data.get("batting_50s_ODI", 0),
72
+ player_data.get("batting_50s_T20", 0),
73
+ player_data.get("batting_50s_IPL", 0)
74
+ ]
75
+ fig, ax = plt.subplots()
76
+ ax.bar(labels, hundreds, label="100s", color="gold")
77
+ ax.bar(labels, fifties, label="50s", color="blue", bottom=hundreds)
78
+ ax.set_ylabel("Count")
79
+ ax.set_title(f"Centuries & Fifties by {selected_player}")
80
+ ax.legend()
81
+ st.pyplot(fig)
82
+
83
+ with col4:
84
+ # Line Chart - Strike Rate & Average
85
+ strike_rate = [
86
+ player_data.get("batting_SR_Test", 0),
87
+ player_data.get("batting_SR_ODI", 0),
88
+ player_data.get("batting_SR_T20", 0),
89
+ player_data.get("batting_SR_IPL", 0)
90
+ ]
91
+ batting_avg = [
92
+ player_data.get("batting_Average_Test", 0),
93
+ player_data.get("batting_Average_ODI", 0),
94
+ player_data.get("batting_Average_T20", 0),
95
+ player_data.get("batting_Average_IPL", 0)
96
+ ]
97
+ fig, ax = plt.subplots()
98
+ ax.plot(labels, strike_rate, marker='o', linestyle='-', color='red', label="Strike Rate")
99
+ ax.plot(labels, batting_avg, marker='s', linestyle='--', color='green', label="Batting Average")
100
+ ax.set_ylabel("Value")
101
+ ax.set_title(f"Strike Rate & Batting Average of {selected_player}")
102
+ ax.legend()
103
+ st.pyplot(fig)
104
+
105
+ # Bar Chart - Balls Faced
106
+ batting_balls = [
107
+ player_data.get("batting_Balls_Test", 0),
108
+ player_data.get("batting_Balls_ODI", 0),
109
+ player_data.get("batting_Balls_T20", 0),
110
+ player_data.get("batting_Balls_IPL", 0)
111
+ ]
112
+ fig, ax = plt.subplots(figsize=(5,3))
113
+ ax.bar(labels, batting_balls, color=["red", "green", "blue", "purple"])
114
+ ax.set_ylabel("Balls Faced")
115
+ ax.set_title(f"Balls Faced by {selected_player}")
116
+ st.pyplot(fig)
117
+
118
  if show_bowling:
119
  st.subheader(f"Bowling Stats for {selected_player}")
120