tonyliu404 commited on
Commit
2a7e086
·
verified ·
1 Parent(s): 722c532

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -429,20 +429,23 @@ if recipe_submit and uploaded_image:
429
  norm = plt.Normalize(min(confidences), max(confidences))
430
  cmap = LinearSegmentedColormap.from_list("grey_orange", ["#808080", "#FFA500"]) #color map grey to orange
431
 
432
- fig, ax = plt.subplots(figsize=(10, 6))
433
  bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
434
 
435
  fig.patch.set_alpha(0) # Transparent background
436
  ax.set_facecolor('none')
437
-
 
438
  # Add labels inside the bars, aligned to the right
439
  for bar in bars:
440
  width = bar.get_width()
 
 
441
  ax.text(width - 0.02, bar.get_y() + bar.get_height()/2, f'{width:.2f}%',
442
- va='center', ha='right', color='white', fontweight='bold')
443
 
444
  ax.set_xticklabels([]) #remove x label
445
- ax.tick_params(axis='y', colors='white')
446
 
447
  #no borders
448
  for spine in ax.spines.values():
 
429
  norm = plt.Normalize(min(confidences), max(confidences))
430
  cmap = LinearSegmentedColormap.from_list("grey_orange", ["#808080", "#FFA500"]) #color map grey to orange
431
 
432
+ fig, ax = plt.subplots(figsize=(12, 6))
433
  bars = ax.barh(class_names, confidences, color=cmap(norm(confidences)))
434
 
435
  fig.patch.set_alpha(0) # Transparent background
436
  ax.set_facecolor('none')
437
+
438
+ min_width = 0.07 * ax.get_xlim()[1] # 7% of the x-axis range
439
  # Add labels inside the bars, aligned to the right
440
  for bar in bars:
441
  width = bar.get_width()
442
+ if width < min_width:
443
+ width = min_width
444
  ax.text(width - 0.02, bar.get_y() + bar.get_height()/2, f'{width:.2f}%',
445
+ va='center', ha='right', color='white', fontweight='bold', fontsize=14)
446
 
447
  ax.set_xticklabels([]) #remove x label
448
+ ax.tick_params(axis='y', colors='white', labelsize=14)
449
 
450
  #no borders
451
  for spine in ax.spines.values():