16

I have the following data:

benchmark   mispredpenal    IPC     pred
ammp        1               1.0589  2lev
ammp        5               1.0450  2lev
...

and use the following command:

ggplot(IPC, aes(x = benchmark, y = IPC, group=mispredpenal, colour=mispredpenal)) + 
  geom_point() + geom_line()

Everything looks like it should, but I would like the legend to be discrete, and not the continuous (gradient). How should I do this?

Edit: Misprediction is either 1, 5, 9, 13 or 17.

user720491
  • 589
  • 1
  • 9
  • 20

1 Answers1

29

You want the variable mispredpenal to be a factor in that case:

ggplot(IPC, aes(x = benchmark, y = IPC, group=factor(mispredpenal), colour=factor(mispredpenal))) + 
  geom_point() + geom_line()
musically_ut
  • 34,028
  • 8
  • 94
  • 106