简体   繁体   中英

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

在此处输入图片说明

What is wrong?

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")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM