Discussion:
The titles of multiple legends do not align with position=“bottom” in ggplot2
trichter
2018-07-05 12:44:32 UTC
Permalink
This question wasnt answered on SO:

library(scales)
library(ggplot2)
df.m <- data.frame(Var1=c("A","B"), Var2=c("B", "A"),
Similarity=c(97.5,92.5),
Rank=c("In", "Out"))

p <- ggplot(df.m, aes(Var1, Var2, fill=Similarity, col=Rank)) +
geom_tile() +
theme_bw()+
theme(legend.position="bottom")+
xlab("") +
ylab("") +
scale_fill_gradient2(low = muted("red"),
mid = "white", high = muted("blue")) +
scale_color_manual(values=c("black", "gold"))

The titles of the legends do not align:

Loading Image...

When i add guides, this happens:

p + guides(color=guide_legend(override.aes = list(fill="white")),
fill=guide_legend(title.hjust=0.5))

Loading Image...
Code hier eingeben...

The legend elements now align, but the continous-nature of the fill-legend
is lost.



One suggestion ist to use legend.box.just = "center", which centers the the
legend titles, but not the legend keys.

Any help would be nice.

Code hier eingeben...
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ***@googlegroups.com
To unsubscribe: email ggplot2+***@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...