Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,24 +57,22 @@ elif option == "Plots":
|
|
57 |
ax1.set_title("Distribution of Jobs Across Categories")
|
58 |
plt.xticks(rotation=45, ha="right")
|
59 |
|
60 |
-
#
|
61 |
-
for
|
62 |
-
|
63 |
-
ax1.text(bar.get_x() + bar.get_width() / 2, yval, int(yval),
|
64 |
-
ha='center', va='bottom', color='black') # Centered above the bar
|
65 |
|
66 |
-
# Adjust layout to give space for
|
67 |
-
plt.subplots_adjust(right=0.
|
68 |
|
69 |
st.pyplot(fig1)
|
70 |
|
71 |
|
|
|
72 |
# 2. Pie Chart for Category Distribution
|
73 |
st.subheader("Job Category Proportions")
|
74 |
fig2, ax2 = plt.subplots(figsize=(10, 10)) # Adjust the size as needed
|
75 |
wedges, texts, autotexts = ax2.pie(
|
76 |
-
category_counts,
|
77 |
-
labels=category_counts.index,
|
78 |
autopct='%1.1f%%',
|
79 |
startangle=140,
|
80 |
colors=plt.cm.Paired.colors # Optional: Change colors for better aesthetics
|
|
|
57 |
ax1.set_title("Distribution of Jobs Across Categories")
|
58 |
plt.xticks(rotation=45, ha="right")
|
59 |
|
60 |
+
# Create a legend with job categories and their counts
|
61 |
+
legend_labels = [f"{category}: {int(count)}" for category, count in zip(category_counts.index, category_counts.values)]
|
62 |
+
ax1.legend(bars, legend_labels, title="Job Categories", loc="upper left", bbox_to_anchor=(1, 1)) # Position the legend
|
|
|
|
|
63 |
|
64 |
+
# Adjust layout to give space for the legend
|
65 |
+
plt.subplots_adjust(right=0.75) # Adjust right margin for legend space
|
66 |
|
67 |
st.pyplot(fig1)
|
68 |
|
69 |
|
70 |
+
|
71 |
# 2. Pie Chart for Category Distribution
|
72 |
st.subheader("Job Category Proportions")
|
73 |
fig2, ax2 = plt.subplots(figsize=(10, 10)) # Adjust the size as needed
|
74 |
wedges, texts, autotexts = ax2.pie(
|
75 |
+
category_counts,
|
|
|
76 |
autopct='%1.1f%%',
|
77 |
startangle=140,
|
78 |
colors=plt.cm.Paired.colors # Optional: Change colors for better aesthetics
|