Hi,
I'm working on a geom_tile() based visualization and I would like to include a legend that indicates how many users each tile represents. I've mocked up what I would like to see below:
Here is my plot code:
ggplot(funnel_df,
aes(x = x, y = y, fill = step_label)) +
geom_tile(size = 1, color = "white") +
scale_fill_discrete(guide = guide_legend(title = "Steps")) +
labs(title = "Checkout Funnel") +
theme_minimal() +
theme(
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.text = element_blank(),
axis.title = element_blank()
)
I attempted to add aes(size =1) thinking that I could then use scale_size_manual to set a manual label to the legend guide. That, however, causes the tiles to disappear:
ggplot(funnel_df,
aes(x = x, y = y, fill = step_label)) +
geom_tile(**aes(size = 1)**, color = "white") +
scale_fill_discrete(guide = guide_legend(title = "Steps")) +
labs(title = "Checkout Funnel") +
theme_minimal() +
theme(
panel.grid.minor = element_blank(),
panel.grid.major = element_blank(),
axis.text = element_blank(),
axis.title = element_blank()
)
I can provide more complete code if needed, but am hoping for suggestions for either:
a) how to add an arbitrary legend or
b) why does setting aes(size = 1) make the tiles disappear?