hertogateis commited on
Commit
23651f1
·
verified ·
1 Parent(s): 08b6390

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -97,17 +97,22 @@ else:
97
 
98
  # If cells are returned, we will extract the corresponding values for plotting
99
  if cells:
100
- # For simplicity, let's assume cells contain data we want to plot (e.g., numeric data)
101
- cell_values = [float(cell['value']) for cell in cells if cell['value'].isnumeric()]
102
- column_names = [cell['column'] for cell in cells]
103
-
104
- # Plot the data
105
- if len(cell_values) > 0 and len(column_names) > 0:
 
 
 
106
  fig, ax = plt.subplots()
107
  ax.bar(column_names, cell_values)
108
- ax.set_xlabel('Columns')
109
  ax.set_ylabel('Values')
110
  ax.set_title('Bar Plot of TAPAS Answer')
 
 
111
  st.pyplot(fig)
112
 
113
  except Exception as e:
 
97
 
98
  # If cells are returned, we will extract the corresponding values for plotting
99
  if cells:
100
+ # Convert cell values from strings to floats for plotting
101
+ cell_values = [float(cell) for cell in cells if cell.replace('.', '', 1).isdigit()]
102
+
103
+ # Plot the data if we have valid numeric values
104
+ if len(cell_values) > 0:
105
+ # Assuming that the coordinates or answer provides context on column names
106
+ # You can adjust the labels or data based on the actual output
107
+ column_names = [f"Row {i+1}" for i in range(len(cell_values))]
108
+
109
  fig, ax = plt.subplots()
110
  ax.bar(column_names, cell_values)
111
+ ax.set_xlabel('Rows')
112
  ax.set_ylabel('Values')
113
  ax.set_title('Bar Plot of TAPAS Answer')
114
+
115
+ # Display the plot in the Streamlit app
116
  st.pyplot(fig)
117
 
118
  except Exception as e: