R 更改ggplot geom_栏上的轴

R 更改ggplot geom_栏上的轴,r,ggplot2,coordinates,R,Ggplot2,Coordinates,我有以下数据帧 View(d.df) Statements | Score | Time -----------+-------+------ Need Ex |4.159 | T1 Need Ex |3.714 | T2 Interest |2.937 | T1 Interest |3.508 | T2 我的阴谋呢 ggplot(data=d.df, aes(x=`Time`,y=Score, fill=`Time`)) + geom_bar(stat="id

我有以下数据帧

View(d.df)
Statements | Score | Time
-----------+-------+------
Need Ex    |4.159  | T1
Need Ex    |3.714  | T2
Interest   |2.937  | T1
Interest   |3.508  | T2
我的阴谋呢

ggplot(data=d.df, aes(x=`Time`,y=Score, fill=`Time`)) +
  geom_bar(stat="identity") +
  scale_fill_manual(values=c("red","blue"))+
  facet_wrap(~Statements)
生成右侧图形,但Y轴比例不是从零开始。我希望Y轴从0到4.5。 我试着加上

+ scale_y_continuous(limits=c(0.0,4.5))
但我得到一个错误,说:

Error: Discrete value supplied to continuous scale
如果我尝试

+ coord_cartesian(ylim=c(0,4.5))
坐标基本保持不变,在底部添加了一点填充。
关于如何使我的轴与此数据成比例地从0移动到4.5,有什么想法吗?

我无法重现您的示例,因为这里的Y从0开始

我最好的猜测是,您的分数列不是数字,而是一个因素,这就是错误所表示的

在打印之前,尝试使用d.df%>%mutateScore=as.numericScore将此列更改为数值