我正在尝试反转 y 轴并将 x 轴放在顶部。一切正常,但是当我尝试在scale_y_reverse()函数中提供一系列 y 轴时,y 轴消失并显示警告消息 -Removed 44 rows containing missing values (geom_point)这是我的代码 -
ggplot(out,aes(x=self_w,y=self_h,col=log(out$force),xlim(0,593),ylim(0,790)))+ geom_point(size=log(out$force))+
scale_fill_continuous(low="green",high="red") +scale_x_continuous(limits=c(0,593),expand=c(0,0),position = "top")+
scale_y_reverse(limits=c(0,790),expand=c(0,0))
Run Code Online (Sandbox Code Playgroud)
这是我的数据集。如果你删除scale_y_reverse()它的参数会正常工作,但这不是我需要的。色标也没有从green到 变化red。有人可以帮我找到问题吗?谢谢。
当您反转轴时,您还需要反转限制。所以改为scale_y_reverse(limits=c(790,0), expand=c(0,0)).
其他一些事情:
将 的所有实例更改out$force为force,因为您不应在aes.
在geom_point,size=log(force)应该被包裹在aes()。
看着你的数据,force往往是零,所以log(force)会-Inf在这些情况下。