missing geom_line

47 views
Skip to first unread message

Tom W

unread,
Mar 6, 2011, 6:18:50 PM3/6/11
to ggplot2
Hey all

I'm missing something fundamental about geom_line. I'm truing to plot
a line between a discrete x variable

library(ggplot2)

Ed<-data.frame(x.1 = c(1,2,3),
y.1 = c(8, 9.5, 2))

print(ggplot(Ed, aes(x = as.factor(x.1), y = y.1)) +
geom_line() +
scale_x_discrete() +
scale_y_continuous())

but this just results in a blank geom. What am I missing?

Thanks

Tom

Ista Zahn

unread,
Mar 6, 2011, 7:41:23 PM3/6/11
to Tom W, ggplot2
The goup asthetic is set to the interaction of all factors in the
plot. You need to override this using aes(goup= )

For example;

ggplot(Ed, aes(x = as.factor(x.1), y = y.1)) +

geom_line(aes(group=1)) +
scale_x_discrete() +
scale_y_continuous()

Best,
Ista

> --
> 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
>

--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

Reply all
Reply to author
Forward
0 new messages