Changing shape in pointrange()

1,264 views
Skip to first unread message

Alexa

unread,
Oct 26, 2010, 10:49:10 PM10/26/10
to ggplot2
Hey all,

I'm using pointrange() so that I have a line graph with points and
error bars. I'd like to be able to change the shape of the points. I'm
trying,


G <- ggplot(new.data,aes(x=X,y=value,linetype=variable))+
geom_line(size = 0.2) +
scale_x_continuous("JD - 2450000", breaks = c(5100, 5150, 5200, 5250,
5300, 5350), labels = c("5100", "5150", "5200", "5250", "5300",
"5350")) +
scale_y_continuous("Intensity (Arbitrary Units)") +
coord_cartesian()

Graph3 <- Graph2 + geom_pointrange(aes(ymax = value + error, ymin =
value - error))
Graph3 + scale_shape_manual(values = c(1,20))

But my scale_shape_manual is not changing anything, I've tried several
values. Any suggestions?

Dennis Murphy

unread,
Oct 27, 2010, 6:12:12 AM10/27/10
to Alexa, ggplot2
Hi:

Where's the shape aesthetic? I see linetype, but that's it. Without defining shape as an aesthetic somewhere (i.e., mapped to values of a variable), scale_shape_* won't (and can't) do anything to the defaults.

HTH,
Dennis


--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

Alexa

unread,
Oct 27, 2010, 11:24:17 AM10/27/10
to ggplot2
I'm using geom_line for the graph and pointrange() in order to have
glyphs at my data points. So I don't think adding shape aesthetic
would do anything since that's not where the points are coming from.
Why doesn't the scale_shape_manual affect shapes made using
pointrange?
> > To unsubscribe: email ggplot2+u...@googlegroups.com<ggplot2%2Bunsu...@googlegroups.com >
> > More options:http://groups.google.com/group/ggplot2

Brandon Hurr

unread,
Oct 27, 2010, 11:34:35 AM10/27/10
to Alexa, ggplot2
If you're not telling it what to assign shapes to then what are you assigning the second shape in your scale manual call? 

+ scale_shape_manual(values = c(1,20))

B

Dennis Murphy

unread,
Oct 27, 2010, 10:02:54 PM10/27/10
to Alexa, ggplot2
Hi:

If you look at the help page for geom_pointrange(), you'll see that one of the arguments is shape.
http://had.co.nz/ggplot2/geom_pointrange.html

Change the default value of 16 to whatever shape number you wish. A list of shapes, along with their numerical codes, is given in Figure B.1, p. 197 of Hadley's ggplot2 book.

HTH,
Dennis




Alexa

unread,
Oct 28, 2010, 9:09:37 AM10/28/10
to ggplot2
Hi,

When I try -

Graph2 + geom_pointrange(shape = c(5, 10), aes(ymax = value + error,
ymin = value - error))

I get an error message saying that aesthetics only takes one value.
I'd like to be able to have my two different data sets have two
different shapes representing them, anyway to do this?

Thanks

On Oct 27, 10:02 pm, Dennis Murphy <djmu...@gmail.com> wrote:
> Hi:
>
> If you look at the help page for geom_pointrange(), you'll see that one of
> the arguments is shape.http://had.co.nz/ggplot2/geom_pointrange.html
> > <ggplot2%2Bunsu...@googlegroups.com<ggplot2%252Bunsubscribe@googlegroup s.com>>

Ben Bolker

unread,
Oct 28, 2010, 9:13:27 AM10/28/10
to Alexa, ggplot2

The "ggplot way", I think, is to merge (i.e. rbind) the two data
frames, adding a factor column that describes which data set each row is
from. Alternatively (much uglier) you can add separate layers with
separate data arguments and shape set manually to different values for each.
Reply all
Reply to author
Forward
0 new messages