user3923765
user3923765

Reputation: 25

Increasing the distance in ggplot

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 ?

Upvotes: 0

Views: 69

Answers (2)

Oneira
Oneira

Reputation: 1445

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)

Upvotes: 0

rnso
rnso

Reputation: 24535

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 ~ .)

Upvotes: 1

Related Questions