Skip to content

ggplot2 qplot pch not working anymore

4 messages · Ben Bolker, stephen sefick

#
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,
#
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)

many thanks,

Stephen Sefick
On 07/17/2012 07:28 PM, Stephen Sefick wrote:

  
    
#
Stephen Sefick <sas0025 <at> auburn.edu> writes:
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
#
Dr. Bolker thank you for the help.  I have figured out how to make this 
do what I wanted - re:inline.  I wanted to use the pch variable as the 
number for the R plotting symbol.  I hope that makes more sense.
kindest regards,

Stephen
On Tue 17 Jul 2012 10:31:07 PM CDT, Ben Bolker wrote:
if you change  the above line of code to

qplot(a,b, shape=pch)+scale_shape_identity()
I will have a look at these soon.