ggplot(top20_baskets, aes(x = reorder(basket_id, total_sales), y = total_sales)) +
geom_col(fill = "darkgreen") +
coord_flip() +
labs(title = "Top 20 Selling Baskets with Sales",
x = "Basket ID",
y = "Total Sales ($)") +
scale_y_continuous(labels = dollar_format()) +
theme_minimal()

ggplot(plot_df, aes(x = basket_id, y = total_sales, fill = income_bucket)) +
geom_col(position = position_dodge(width = 0.8), width = 0.72) +
coord_flip() +
labs(
title = "Top 20 Baskets by Sales, Split by Income Group",
x = "Basket ID",
y = "Sales ($)",
fill = "Income"
) +
scale_y_continuous(labels = dollar_format()) +
theme_minimal() +
annotate("segment",
x = "33347880492", xend = "33347880492",
y = 500, yend = 700, # adjust these numbers
colour = "black", size = 1,
arrow = arrow(length = unit(0.25, "cm"))) +
annotate("text",
x = "33347880492", y = 750, # adjust y higher than bar
label = "Let's look at \nwhat is in this\nbasket",
colour = "black", hjust = 0)

ggplot(basket_top5, aes(x = sales, y = names)) +
geom_col(fill = "maroon") +
labs(
title = paste("Top 5 Items in the Highest Grossing Basket among Low Income Households"),
x = "Dollar Value ($)",
y = "Product"
) +
coord_flip()
