[R] ggplot2 - legend for fill coulours
Pedro de Barros
pbarros at ualg.pt
Tue Apr 1 21:58:12 CEST 2008
Hadley,
Thanks a lot!
BTW, do you have any document explaining the object philosophy of
ggplot? I was trying to see how you defined scale_fill_identity, but
could not find it...
Cheers,
Pedro
At 19:50 2008/04/01, hadley wickham wrote:
> > However, it looks this works only when the data are in the sequence
> > of the levels in the factor defining the fill colours. When the
> > sequence is different, the legend gets "scrambled", in that the order
> > of the colours does not match the labels.
>
>You can fix this by explicitly specifying the breaks to use in the
>identity scale:
>
> + scale_fill_identity(labels=levels(plotdata2$group),
>breaks=levels(plotdata2$group))
>
>That way there's no confusion about how the values and their labels match up.
>
>Regards,
>
>Hadley
>
>--
>http://had.co.nz/
More information about the R-help
mailing list