Spaces:
Sleeping
Sleeping
tonyliu404
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -16,6 +16,7 @@ from PIL import Image
|
|
16 |
import json
|
17 |
import matplotlib.pyplot as plt
|
18 |
from matplotlib.colors import LinearSegmentedColormap
|
|
|
19 |
|
20 |
st.set_page_config(
|
21 |
page_title="Food Chain",
|
@@ -450,7 +451,21 @@ if recipe_submit and uploaded_image:
|
|
450 |
va='center', ha='right', color='white', fontweight='bold', fontsize=16)
|
451 |
|
452 |
ax.set_xticklabels([]) #remove x label
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
|
455 |
#no borders
|
456 |
for spine in ax.spines.values():
|
|
|
16 |
import json
|
17 |
import matplotlib.pyplot as plt
|
18 |
from matplotlib.colors import LinearSegmentedColormap
|
19 |
+
import textwrap
|
20 |
|
21 |
st.set_page_config(
|
22 |
page_title="Food Chain",
|
|
|
451 |
va='center', ha='right', color='white', fontweight='bold', fontsize=16)
|
452 |
|
453 |
ax.set_xticklabels([]) #remove x label
|
454 |
+
|
455 |
+
|
456 |
+
# ax.tick_params(axis='y', colors='white', labelsize=16)
|
457 |
+
|
458 |
+
# Define the maximum width (in terms of number of characters)
|
459 |
+
max_label_width = 10
|
460 |
+
|
461 |
+
# Get current tick labels
|
462 |
+
labels = ax.get_yticklabels()
|
463 |
+
|
464 |
+
# Wrap the labels if they exceed the max width
|
465 |
+
wrapped_labels = [textwrap.fill(label.get_text(), width=max_label_width) for label in labels]
|
466 |
+
|
467 |
+
# Set the wrapped labels back to the y-ticks
|
468 |
+
ax.set_yticklabels(wrapped_labels, fontsize=16, color='white')
|
469 |
|
470 |
#no borders
|
471 |
for spine in ax.spines.values():
|