Reputation: 18918
I have a data frame trajectory_df
that has the following structure:
The uid
row has 6 different possible values, each representing a particular user. So I want to plot 6 lines on the same plot, and I'm currently doing it in this way:
ggplot(trajectory_df, aes(Month, Pagerank, colour=uid, group=uid)) + geom_line() + geom_point() + scale_x_discrete(breaks=month_ticks)
Which gives me this picture:
Which is just what I want, except for the legend. I want there to be 6 different entries in the legend, not a colorful range of values.
How can I accomplish this?
Upvotes: 3
Views: 203
Reputation: 173517
Try this instead:
ggplot(trajectory_df, aes(Month, Pagerank, colour=factor(uid), group=uid)) +
geom_line() +
geom_point() +
scale_x_discrete(breaks=month_ticks)
Upvotes: 6