How do I create a legend with ggplot? I think should be getting the FuelTypeNum in the legend.
Plot: http://r.789695.n4.nabble.com/file/n4632471/Rplot.jpeg My code is: ggplot(data=tempTable, aes(x=Bands8, y=SubPercent, fill=FuelTypeNum)) + geom_bar(position="stack", stat="identity") + scale_colour_hue('my legend', breaks = levels(tempTable$FuelTypeNum), labels=c('Bio', 'Coal', 'Gas', 'Hydro','Other')) tempTable: FuelTypeNum Bands8 AvailableMW AvailableMWNewFormat SubPercent 1 1 PB0 185351 185.351 4.355864e-03 2 2 PB0 25994753 25994.753 6.108928e-01 3 4 PB0 1369528 1369.528 3.218476e-02 4 5 PB0 14522521 14522.521 3.412883e-01 5 10 PB0 479915 479.915 1.127830e-02 6 2 PB1 48229 48.229 5.736753e-02 7 5 PB1 792473 792.473 9.426325e-01 8 2 PB2 11792402 11792.402 7.914544e-01 9 4 PB2 27187 27.187 1.824672e-03 10 5 PB2 2770769 2770.769 1.859619e-01 11 10 PB2 309303 309.303 2.075906e-02 12 1 PB3 48 0.048 3.983475e-05 13 2 PB3 136844 136.844 1.135656e-01 14 4 PB3 65079 65.079 5.400845e-02 15 5 PB3 793226 793.226 6.582909e-01 16 10 PB3 209781 209.781 1.740953e-01 17 1 PB4 22113 22.113 4.340998e-02 18 2 PB4 57843 57.843 1.135515e-01 19 4 PB4 20315 20.315 3.988033e-02 20 5 PB4 382714 382.714 7.513050e-01 21 10 PB4 26414 26.414 5.185326e-02 22 1 PB5 39173 39.173 3.232381e-02 23 2 PB5 174913 174.913 1.443304e-01 24 4 PB5 103542 103.542 8.543824e-02 25 5 PB5 874764 874.764 7.218162e-01 26 10 PB5 19501 19.501 1.609135e-02 27 1 PB6 4 0.004 4.550429e-06 28 2 PB6 175038 175.038 1.991245e-01 29 4 PB6 91547 91.547 1.041445e-01 30 5 PB6 610371 610.371 6.943625e-01 31 10 PB6 2078 2.078 2.363948e-03 32 1 PB7 36103 36.103 1.109041e-02 33 2 PB7 210681 210.681 6.471866e-02 34 4 PB7 739013 739.013 2.270159e-01 35 5 PB7 2239824 2239.824 6.880469e-01 -- View this message in context: http://r.789695.n4.nabble.com/ggplot-incorrect-legend-tp4632471.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.