我有以下代码段。当我绘制第一张图时,我将绘制点的颜色作为颜色渐变。然而,当我绘制第二个图形时,我得到了绘制点的不同颜色。我希望图1中的绘制点具有相似的颜色,如图2所示。请帮助。
area<-c(1:21)
time<-c('11','11','11','11','11','00','11','11','11','11','11','11','11','11','11','11','11','11','11','11','11')
freq<-c(10,12,3,5,8,15,20,16,30,34,50,40,45,35,31,21,27,17,19,11,49)
time2<-c('1','2','3','4','5','6','7','8','9','10','1','2','3','4','5','6','7','8','9','10','11')
df<-data.frame(area,time,time2,freq)
qplot(x=time,y=freq,data = df,geom = 'point',
color = area,xlab="Hours of the Day",
ylab="Maximum Frequency of Crimes in Area",
main = "Affected Areas according to time of Occurrence")+
scale_y_continuous(limits = c(0,50),breaks = seq(0,50,2))+
theme(plot.title = element_text(hjust = 0.5))
qplot(x=time,y=freq,data = df,geom = 'point',
color = time2,xlab="Hours of the Day",
ylab="Maximum Frequency of Crimes in Area",
main = "Affected Areas according to time of Occurrence")+
scale_y_continuous(limits = c(0,50),breaks = seq(0,50,2))+
theme(plot.title = element_text(hjust = 0.5))
谢谢。