[R] setting axis limits and breaks in ggplot2
Sarah Goslee
sarah.goslee at gmail.com
Fri Jul 18 23:18:10 CEST 2014
You need to explicitly specify the limits; see
http://docs.ggplot2.org/current/scale_continuous.html
library(ggplot2)
test<-data.frame(a=1:4,b=c(0.12,0.5,0.6,0.4))
ggplot(test, aes(x=a, y=b))+geom_line()+
scale_x_continuous(breaks=1:4)+
scale_y_continuous(breaks=seq(0,1,by=0.1), limits=c(0,1))
Sarah
On Fri, Jul 18, 2014 at 5:04 PM, Dimitri Liakhovitski
<dimitri.liakhovitski at gmail.com> wrote:
> Hello!
>
> I want my y axis in this plot to range from 0 to 1 and use as break points
> 0, 0.1, 0.2 up to 1.
> Why is my code below not working?
>
> Thank you!
>
> library(ggplot2)
> test<-data.frame(a=1:4,b=c(0.12,0.5,0.6,0.4))
>
> ggplot(test, aes(x=a, y=b))+geom_line()+
> scale_x_continuous(breaks=1:4)+
> scale_y_continuous(breaks=seq(0,1,by=0.1))
>
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list