Question

I'm having trouble manipulating ggbiplot such that I can specify what the title of the legend is. Using the package data:

library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
p <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class, 
              ellipse =  TRUE, circle = TRUE)

I've tried the following

p + scale_fill_discrete(name="New Title")
p + guides(fill=guide_legend(title="New Legend Title"))

but I have no luck with either. I was wondering if somebody was familiar with this package and was able to advise as to how to change the legend title.

Was it helpful?

Solution

As you are plotting points and their aesthetics is color and accordingly you should use color= instead of fill=

p+guides(color=guide_legend("Legend title"))

or

p + labs(color="Legend title")

OTHER TIPS

In the meantime it works with scale_color_discrete(name = 'Legend title').

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top