ggplot2 似乎将不同的点放在相同的 x 位置?

ggplot2 seemingly places distinct points at the same x position?

我在使用 ggplot2 绘图时遇到问题。我正在尝试显示一组点,其中 x 轴是年份,y 轴是浮点数。有两个方面,'type' 和 'group' 分别有 4 个和 2 个值。奇怪的是,不同的年份值似乎位于图中的同一年份位置。我假设我做错了什么,但不确定是什么。

library(ggplot2)

csv <- '"","year","type","meanPM2.5","group"
"1","1999","NON-ROAD",0.650193156943192,"Baltimore"
"2","1999","NONPOINT",53.8128535945545,"Baltimore"
"3","1999","ON-ROAD",0.384811951879435,"Baltimore"
"4","1999","POINT",23.7744225574713,"Baltimore"
"5","2002","NON-ROAD",0.556466983374061,"Baltimore"
"6","2002","NONPOINT",33.4348242946658,"Baltimore"
"7","2002","ON-ROAD",0.173168130596644,"Baltimore"
"8","2002","POINT",14.131129233003,"Baltimore"
"9","2005","NON-ROAD",0.512356196792363,"Baltimore"
"10","2005","NONPOINT",31.8169245427152,"Baltimore"
"11","2005","ON-ROAD",0.148555691013436,"Baltimore"
"12","2005","POINT",13.6351701910803,"Baltimore"
"13","2008","NON-ROAD",0.295555123686582,"Baltimore"
"14","2008","NONPOINT",20.8642755980118,"Baltimore"
"15","2008","ON-ROAD",0.117856744706526,"Baltimore"
"16","2008","POINT",2.24419944428104,"Baltimore"
"17","1999","NON-ROAD",5.81044444444444,"Total"
"18","1999","NONPOINT",84.305,"Total"
"19","1999","ON-ROAD",1.80635416666667,"Total"
"20","1999","POINT",22.8303846153846,"Total"
"21","2002","NON-ROAD",2.16979209254948,"Total"
"22","2002","NONPOINT",41.9305555555556,"Total"
"23","2002","ON-ROAD",0.418407542677101,"Total"
"24","2002","POINT",8.49641791044776,"Total"
"25","2005","NON-ROAD",2.2426458532036,"Total"
"26","2005","NONPOINT",41.9305555555556,"Total"
"27","2005","ON-ROAD",0.402562900882384,"Total"
"28","2005","POINT",16.9364788732394,"Total"
"29","2008","NON-ROAD",0.536765014018269,"Total"
"30","2008","NONPOINT",30.5157179549356,"Total"
"31","2008","ON-ROAD",0.313033536852635,"Total"
"32","2008","POINT",1.28722083560821,"Total"'

w <- read.csv(text = csv)
qplot(w$year, w$meanPM2.5, data=w, facets = type~group)

无需为轴指定 w,因为它的 qplot 已经从数据参数中知道了这一点。见下文,它给了我预期的结果。

qplot(year, meanPM2.5, data=w, facets = type~group)