Soumendra
Soumendra

Reputation: 1202

ggplot failing to plot the correct color

ggplot2 seems to have gone haywire in my machine. No matter what color I specify, it seems to print the lines in red! For example, the following code also prints the plot in red (image attached).

df <- data.frame(
  date = seq(Sys.Date(), len=100, by="1 day")[sample(100, 50)],
  price = runif(50)
)
df <- df[order(df$date), ]

dt <- qplot(date, price, data=df, geom="line", color="blue")
dt

enter image description here

What is wrong?

Upvotes: 1

Views: 1649

Answers (1)

Arun
Arun

Reputation: 118889

Replace colour = "blue" with this instead:

colour = I("blue")

As @joran rightly mentions, it's better to do it this way instead:

ggplot(data=df, aes(date, price)) + geom_line(color="blue")

Upvotes: 1

Related Questions