0
ggplot(data = sortmax, aes(x = Date, y = price, colour = Grade)) +geom_line(aes(group = Grade)) + geom_point()  

I have five different graphs for five different grades . All the graphs are intersecting and over writing each other because of common values of price on y axis. How can I increase the distance between all these graphs ?

2 Answers2

1

It will be useful if you can post output of command: dput(sortmax)

You can try separating the graphs completely by using facet_grid:

ggplot(data = sortmax, aes(x = Date, y = price, color=Grade)) +
    geom_line() +
    geom_point()+
    facet_grid(Grade ~ .)
rnso
  • 23,686
  • 25
  • 112
  • 234
  • using facet_grid(Grade ~ .) throws error message "At least one layer must contain all variables used for facetting" . I cannot show output because I dont have reputation of 10 . I am very new – user3923765 Aug 13 '14 at 17:33
  • `dput(sortmax)` returns text, you'll be able to include it in your question. – Brandon Bertelsen Aug 13 '14 at 17:38
0

If you group your data only by one variable, you can also use facet_wrap. If 5 different Grade result in a too wide plot you can choose to add nrow or ncol (number of rows/columns) argument to adjust the final layout

Variant of rnso answer:

ggplot(data = sortmax, aes(x = Date, y = price, color=Grade)) +
    geom_line() +
    geom_point()+
    facet_wrap(~Grade,nrow=2)
Oneira
  • 1,365
  • 1
  • 14
  • 28