Thank you both, very much. Using the identity function I() is a very nice trick, but it still feels like a trick.
Using ggplot makes the most sense to me. ggplot(df, aes(x=x, y=y, colour=factor(type))) + geom_point(size=1) + geom_smooth() Thank you very much for taking the time to explain the syntax. I had tried using the ggplot function, but I couldn't figure out how to handle the"colour=factor(type)" part. (my erroneous formulas are omitted for clarity) On Tue, Jan 25, 2011 at 12:06 PM, Brian Diggs <dig...@ohsu.edu> wrote: > On 1/25/2011 9:44 AM, Felipe Carrillo wrote: > >> try this: >> qplot(x, y, data=df, colour=factor(type), size=I(1)) + geom_smooth() >> > > Felipe very nicely answered the "how" of your question. I thought I'd > followup with the "why." > > Using qplot, it assumes that you are giving a set of aesthetic mappings. > As such, size is being mapped to a variable that is 1 for all entries. > Then, in the usual way, a mapping is created between values of the variable > in the data space and in the aesthetic space (actual sizes) and a legend is > created to display this mapping. Enclosing the 1 in an I() indicates that > you are giving a literal value to set the aesthetic to, in which case no > mapping between aesthetic and data space (nor legend) is needed. > > Alternatively, you can use an identity scale to state that the data and > aesthetic spaces are the same, and tell it to not plot the legend. > > > qplot(x, y, data=df, colour=factor(type), size=1) + > geom_smooth() + > scale_size_identity(legend=FALSE) > > The distinction between aesthetic mapping and setting is even more evident > in ggplot notation: > > ggplot(df, aes(x=x, y=y, colour=factor(type))) + > geom_point(size=1) + > > geom_smooth() > > > Felipe D. Carrillo >> Supervisory Fishery Biologist >> Department of the Interior >> US Fish& Wildlife Service >> California, USA >> http://www.fws.gov/redbluff/rbdd_jsmp.aspx >> >> >> >> >> ----- Original Message ---- >> >>> From: Gene Leynes<gleyne...@gmail.com <gleynes%...@gmail.com>> >>> To: r-help@r-project.org >>> Sent: Tue, January 25, 2011 9:28:20 AM >>> Subject: [R] ggplot - controlling point size >>> >>> Can anyone illuminate the following for me? >>> How can I get rid of the blue line in the key in the second plot? >>> >>> ## Create a simple data frame >>> df=data.frame(x=1:1000, y=2*1:1000+rnorm(1000,sd=1000), >>> type=sample(letters[1:2],1000, replace=TRUE)) >>> >>> ## Very nice! Almost what I want >>> qplot(x, y, data=df, colour=factor(type)) + geom_smooth() >>> >>> ## Make a nicer plot, with smaller points >>> ## but why does that add the little blue line with a 1? >>> qplot(x, y, data=df, colour=factor(type), size=1) + geom_smooth() >>> >> > -- > Brian S. Diggs, PhD > Senior Research Associate, Department of Surgery > Oregon Health & Science University > [[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.