eaglelandsonce commited on
Commit
ddaf69f
·
verified ·
1 Parent(s): 75cadaa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -14,15 +14,18 @@ num_dots = st.number_input('Number of dots', min_value=1, max_value=10, value=5)
14
  chart_placeholder = st.empty()
15
 
16
  while True: # This loop will simulate real-time data updates
17
- # Initialize an empty DataFrame for the new data points
18
- new_data = pd.DataFrame(columns=['x', 'y'])
19
 
20
  # Generate random x and y positions within the specified radius for the specified number of dots
21
  for _ in range(num_dots):
22
  new_x = random.uniform(-radius, radius)
23
  new_y = random.uniform(-radius, radius)
24
- # Append the new data point to the DataFrame
25
- new_data = new_data.append({'x': new_x, 'y': new_y}, ignore_index=True)
 
 
 
26
 
27
  # Create a new Plotly figure for the scatter plot
28
  fig = px.scatter(new_data, x='x', y='y', title="Random Dots within a Radius")
 
14
  chart_placeholder = st.empty()
15
 
16
  while True: # This loop will simulate real-time data updates
17
+ # Create a list to hold the new data points
18
+ new_data_points = []
19
 
20
  # Generate random x and y positions within the specified radius for the specified number of dots
21
  for _ in range(num_dots):
22
  new_x = random.uniform(-radius, radius)
23
  new_y = random.uniform(-radius, radius)
24
+ # Append the new data point as a dictionary to the list
25
+ new_data_points.append({'x': new_x, 'y': new_y})
26
+
27
+ # Create a new DataFrame from the list of new data points
28
+ new_data = pd.DataFrame(new_data_points)
29
 
30
  # Create a new Plotly figure for the scatter plot
31
  fig = px.scatter(new_data, x='x', y='y', title="Random Dots within a Radius")