This is my script to display with Seaborn a barplot Stacked:
# Initialize the plot
sns.set(style="whitegrid")
fig, ax = plt.subplots(figsize=(20,12))
# Create the stacked bar chart
sns.barplot(data=df_sorted, y='SalesRepFullName', x='SaleOrderTotal', palette='viridis', label='SaleOrderTotal')
# Add annotations for DaysSalesRep values
for index, row in df_sorted.iterrows():
plt.text(row['SaleOrderTotal'] + 1000, index, f"{row['DaysSalesRep']} days", color='black', va='center',fontsize=9)
# Set the plot title and labels
plt.title('Sales Data: DaysSalesRep vs. SaleOrderTotal')
plt.xlabel('Sale Order Total')
plt.ylabel('Sales Representative')
# Formatting the x-axis labels as USD dollars
formatter = ticker.StrMethodFormatter('US {x:.0f}')
ax.xaxis.set_major_formatter(formatter)
# Formatting the x-axis labels
plt.xticks(rotation=45, ha='center')
# Display the plot
fig.tight_layout()
plt.show()
Why my labels are not displaying properly?