Reputation: 907
I am trying to reverse the y axis and put the x axis on top. Everything is working fine but when i try to provide a range of y axis in scale_y_reverse()
function the y axis got disappeared and show a warning message - Removed 44 rows containing missing values (geom_point)
Here is my code-
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))
Here is my dataset. If you delete the arguments of scale_y_reverse()
it will work fine but that's not what i need. Also the color scale is not achanging from green
to red
. Can anybody help me to find the problem? Thanks.
Upvotes: 5
Views: 7464
Reputation: 93871
When you reverse the axis, you also need to reverse the limits. So change to scale_y_reverse(limits=c(790,0), expand=c(0,0))
.
A few other things:
Change all instances of out$force
to force
, as you shouldn't restate the data frame name within aes
.
In geom_point
, size=log(force)
should be wrapped in aes()
.
Looking at your data, force
is often zero, so log(force)
will be -Inf
in those cases.
Upvotes: 11