[R] ggplot2 qplot pch not working anymore

Ben Bolker bbolker at gmail.com
Wed Jul 18 05:31:07 CEST 2012


Stephen Sefick <sas0025 <at> auburn.edu> writes:


> I'm sorry I didn't give the correct code, or explaination;  the 
> shape=pch doesn't work anymore.  For example this used to work, but no 
> longer can accept continuous values:
> 
> #example code
> a <- 1:10
> b <- 1:10
> pch <- 1:10
> 
> q <- data.frame(a,b,pch)
> 
> qplot(a,b, shape=pch)

  Not entirely clear what you want it to do: how *would* you
map a continuous variable onto shape (assuming you're not
using something like Chernoff faces)?  Does

qplot(a,b,shape=factor(pch,levels=1:10))

do what you want?

A couple of possibly useful recent Stack Overflow posts
(URLs broken):

http://stackoverflow.com/questions/10002627/
ggplot2-0-9-0-automatically-dropping-unused-factor-levels-from-plot-legend

http://stackoverflow.com/questions/11361404/
consistent-legend-colors-with-qplot



 
> many thanks,
> 
> Stephen Sefick
> 
> On 07/17/2012 07:28 PM, Stephen Sefick wrote:
> > Is there a way to use a continuous variable to pch in qplot?  I 
> > believe this worked in previous version.  I need to specify certain 
> > values of a shape for particular points so that multiple graphs all 
> > show the same shapes for the same streams.  I have gone to the 
> > original data and added a pch column that I would like to use to 
> > specify the shapes to pch in qplot.  Any help would be greatly 
> > appreciated.
> >
> > #example code
> > a <- 1:10
> > b <- 1:10
> > pch <- 1:10
> >
> > q <- data.frame(a,b,pch)
> >
> > qplot(a,b, pch=pch)
> >
> > Many thanks,
> >
>



More information about the R-help mailing list