I'm using ggplot to make a graph with the legend positioned horizontally above the plot. There are multiple legends for my variables (ie color, shape, linetype).
+ theme(legend.position = 'top', legend.direction = "horizontal", legend.box = "horizontal")
Is there anyway to put the title of each legend above the descriptions rather than to the side
and/or
place the key above the label text.
Something like adding guides(...)
for each aesthetic?
ggplot(diamonds, aes(depth, price, color = cut)) +
geom_point() +
theme(legend.position = 'top',
legend.direction = "horizontal",
legend.box = "horizontal") +
guides(color = guide_legend(title.position = "top",
# hjust = 0.5 centres the title horizontally
title.hjust = 0.5,
label.position = "bottom"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With