我有以下情节:
它是使用以下代码创建的:
ggplot(data=new.data, mapping=aes(x= m.speed*1.09728, y=m.gaptime)) +
geom_point(aes(shape=interaction(Vehicle.class,PrecVehClass)), size=3, fill="black") +
scale_shape_manual(values=c(1,25,12), name="Vehicle Following Case",
labels = c("Car Following Car", "Truck Following Car", "Car Following Truck")) +
stat_smooth(aes(x= m.speed*1.09728, y=m.gaptime, linetype=interaction(Vehicle.class,PrecVehClass)),size=1,color="black",method="loess", alpha=0) +
scale_linetype_manual(values=c("dotted", "solid", "longdash"), name="Vehicle Following Case",
labels = c("Car Following Car", "Truck Following Car", "Car Following Truck")) +
scale_x_discrete(breaks=seq(5,90, by=5)) +
labs(x='Mean Speed (Km/hr)', y='Mean Time Gap (s)') +
theme_bw() + my.theme()
您可以看到x轴(75)上的最后一个刻度标记位于绘图的边界,左边的第一个框不包含任何数据。我在limits
中尝试了不同的breaks
和scale_discrete
,如代码所示,但无法解决此问题。请帮忙。