Mary: Here's one way. ## change the variable name to whatever title you want on your legend data = melt(data, id="inputs",variable_name="customName") data g <- ggplot(data,aes(x=inputs, value, colour= customName, fill = customName, shape=customName)) g <- g + geom_line(lwd=0.8) g <- g + geom_point() g <- g + scale_x_continuous(name='Number of inputs') g <- g + scale_y_continuous('Conversion time (sec.)')
Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish & Wildlife Service California, USA http://www.fws.gov/redbluff/rbdd_jsmp.aspx From: Mary Kindall <mary.kind...@gmail.com> >To: r-help@r-project.org >Sent: Monday, January 16, 2012 1:14 PM >Subject: [R] ggplot- using geom_point and geom_line at the same time > >Hi >I am plotting line chart using ggplot and want to use geom_line and >geom_point simultaneously. I want to rename my legend but uptonow I remain >unsuccessful. >Someone please point what to add for renaming the legend. >I attached my example below. >Thanks > > > >con = textConnection("inputs var1 var2 var3 >100 10 5 2 >1000 20 10 4 >5000 30 15 8 >10000 40 20 16 >30000 50 25 32") >data = read.table(con, header=TRUE) >data >data = melt(data, id="inputs") >g <- ggplot(data,aes(x=inputs, value, colour= variable, fill = variable, >shape=variable)) >g <- g + geom_line(lwd=0.8) >g <- g + geom_point() >g <- g + scale_x_continuous(name='Number of inputs') >g <- g + scale_y_continuous('Conversion time (sec.)') >g > > > >-- >------------- >Mary Kindall >Yorktown Heights, NY >USA > > [[alternative HTML version deleted]] > >______________________________________________ >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. > > > [[alternative HTML version deleted]]
______________________________________________ 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.