我如何比较r中的两个数据

时间:2017-05-05 17:43:12

标签: r plot ggplot2

x <- c(466.0916, 496.7208, 508.8113, 516.8716, 524.9319)

y <- c(281.6531, 306.3963, 452.0596, 597.9728, 775.5842)

在图中,例如x显示为红色,y显示为蓝色。这是怎么做到的?

1 个答案:

答案 0 :(得分:-1)

这是一个简单的答案,但我不确定你想要什么

x <- c(466.0916, 496.7208, 508.8113, 516.8716, 524.9319)

y <- c(281.6531, 306.3963, 452.0596, 597.9728, 775.5842)


dtY<-data.frame(x=x,y=y)

library(ggplot2)
p <- ggplot(NULL, aes( x=x,y=y)) + 
  geom_point(stat="identity",aes(fill = "X"), data =dtY , alpha = 0.5)
p