1

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.

rcs
  • 67,191
  • 22
  • 172
  • 153
Nick Crouch
  • 301
  • 3
  • 14

2 Answers2

6

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")
Didzis Elferts
  • 95,661
  • 14
  • 264
  • 201
1

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

Anca
  • 157
  • 3
  • 7