SmallChess
SmallChess

Reputation: 8117

Unable to plot multiple line plots in the same graph

I have the following code and I want to draw two lines, both specified in the same data frame. However, I'm getting big coloured shadows, and I'm not able to figure out the cause. The data and the code look correct to me...

library('ggplot2')
library('reshape2')

df <- read.csv(url("http://smallchess.com/test.csv"), row.names=1)
melted = melt(df, id.vars='time')
p <- ggplot(data=melted, aes(x=time, y=value, group=variable, colour=variable)) + geom_line()
print(p)

enter image description here

Upvotes: 1

Views: 203

Answers (1)

loki
loki

Reputation: 10350

The two variables show extremely oscillating values. So that each line overlaps its neighbor. Thus, this opaque structure is generated. Perhaps it helps if you set your size of the line to a low value like this:

p <- ggplot(data=melted, aes(x=time, y=value, group=variable, colour=variable)) + 
  geom_line(size = 0.05)
print(p)

enter image description here

Upvotes: 4

Related Questions