CultriX commited on
Commit
060f927
1 Parent(s): 6de98b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -2
app.py CHANGED
@@ -109,9 +109,52 @@ def create_bar_chart(df, category):
109
  st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
110
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
 
114
-
115
  # Main function to run the Streamlit app
116
  def main():
117
  # Set page configuration and title
@@ -201,7 +244,7 @@ def main():
201
  )
202
 
203
  # Full-width plot for the first category
204
- create_bar_chart(df, score_columns[0])
205
 
206
  # Next two plots in two columns
207
  col1, col2 = st.columns(2)
 
109
  st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
110
 
111
 
112
+ import plotly.graph_objs as go
113
+ import streamlit as st
114
+
115
+ def create_combined_chart(df, category):
116
+ """Create and display a combined bar and line chart for a given category."""
117
+ st.write(f"### {category} Scores")
118
+
119
+ # Sort the DataFrame based on the category score
120
+ sorted_df = df[['Model', category]].sort_values(by=category, ascending=True)
121
+
122
+ # Create a figure
123
+ fig = go.Figure()
124
+
125
+ # Add bar graph to the figure
126
+ fig.add_trace(
127
+ go.Bar(
128
+ x=sorted_df['Model'],
129
+ y=sorted_df[category],
130
+ name='Bar Chart',
131
+ marker=dict(color=sorted_df[category], colorscale='Spectral') # You can change the color
132
+ )
133
+ )
134
+ # Add line graph to the figure
135
+ fig.add_trace(
136
+ go.Scatter(
137
+ x=sorted_df['Model'],
138
+ y=sorted_df[category],
139
+ mode='lines',
140
+ name='Line Chart',
141
+ line=dict(color='red') # You can change the line color
142
+ )
143
+ )
144
+
145
+ # Update layout if needed
146
+ fig.update_layout(
147
+ title=f"{category} Scores",
148
+ xaxis_title="Model",
149
+ yaxis_title=f"{category} Value",
150
+ margin=dict(l=20, r=20, t=20, b=20)
151
+ )
152
+
153
+ # Display the figure in Streamlit
154
+ st.plotly_chart(fig, use_container_width=True, height=len(df) * 35)
155
+
156
 
157
 
 
158
  # Main function to run the Streamlit app
159
  def main():
160
  # Set page configuration and title
 
244
  )
245
 
246
  # Full-width plot for the first category
247
+ create_combined_chart(df, score_columns[0])
248
 
249
  # Next two plots in two columns
250
  col1, col2 = st.columns(2)