vgosavi2 commited on
Commit
48e53e1
·
verified ·
1 Parent(s): b50d348

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +6 -6
src/streamlit_app.py CHANGED
@@ -305,23 +305,23 @@ fig.update_layout(
305
  # 4. Render in Streamlit
306
  st.plotly_chart(fig, use_container_width=True)
307
  ##########################################################
308
- # Aggregate total incidents by region and take top 15
309
  region_counts = (
310
  df.groupby("RegionName")
311
  .size()
312
  .reset_index(name="Count")
313
- .nlargest(15, "Count")
314
  )
315
 
316
  # 2. Compute circle‐packing layout
317
  circles = circlify.circlify(
318
  region_counts["Count"].tolist(),
319
  show_enclosure=False,
320
- target_enclosure=circlify.Circle(x=0, y=0, r=1)
321
  )
322
 
323
  # 3. Plot packed bubbles
324
- fig, ax = plt.subplots(figsize=(6, 6))
325
  ax.axis("off")
326
 
327
  # Determine plot limits so everything fits
@@ -339,10 +339,10 @@ for circle, (_, row) in zip(circles, region_counts.iterrows()):
339
  ax.text(
340
  x, y,
341
  f"{row['RegionName']}\n{row['Count']:,}",
342
- ha="center", va="center", fontsize=8
343
  )
344
 
345
- ax.set_title("Packed Bubble: Top 15 Regions by Incident Count", fontsize=14)
346
 
347
  # 4. Render in Streamlit
348
  st.pyplot(fig)
 
305
  # 4. Render in Streamlit
306
  st.plotly_chart(fig, use_container_width=True)
307
  ##########################################################
308
+ # Aggregate total incidents by region and take top 10
309
  region_counts = (
310
  df.groupby("RegionName")
311
  .size()
312
  .reset_index(name="Count")
313
+ .nlargest(10, "Count")
314
  )
315
 
316
  # 2. Compute circle‐packing layout
317
  circles = circlify.circlify(
318
  region_counts["Count"].tolist(),
319
  show_enclosure=False,
320
+ target_enclosure=circlify.Circle(x=0, y=0, r=0.5)
321
  )
322
 
323
  # 3. Plot packed bubbles
324
+ fig, ax = plt.subplots(figsize=(3, 3))
325
  ax.axis("off")
326
 
327
  # Determine plot limits so everything fits
 
339
  ax.text(
340
  x, y,
341
  f"{row['RegionName']}\n{row['Count']:,}",
342
+ ha="center", va="center", fontsize=8, color="#222"
343
  )
344
 
345
+ ax.set_title("Packed Bubble: Top 15 Regions by Incident Count", fontsize=12, pad=10)
346
 
347
  # 4. Render in Streamlit
348
  st.pyplot(fig)