Try making FuelTypeNum into a factor like this: p <- ggplot(data=tempTable, aes(x=Bands8, y=AvailableMWNewFormat, fill=as.factor(FuelTypeNum))) + geom_bar(position="stack", stat="identity")+ coord_flip() p
John Kane Kingston ON Canada > -----Original Message----- > From: ja...@crosb.ie > Sent: Wed, 6 Jun 2012 09:29:24 -0700 (PDT) > To: r-help@r-project.org > Subject: Re: [R] ggplot incorrect legend > > Thank you for your help. > > I would expect FuelTypeNum to make up the legend. But in the legend > there > is an extra value of called '3' and in the chart there is an extra > FuelTypeNum. > > code: > ggplot(data=tempTable, aes(x=Bands8, y=AvailableMWNewFormat, > fill=FuelTypeNum)) + > geom_bar(position="stack", stat="identity") + > coord_flip() > > Plot > http://r.789695.n4.nabble.com/file/n4632552/Rplot.jpeg > > Data: > http://r.789695.n4.nabble.com/file/n4632552/dataRtest.csv dataRtest.csv > > -- > View this message in context: > http://r.789695.n4.nabble.com/ggplot-incorrect-legend-tp4632471p4632552.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. ____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop! ______________________________________________ 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.