C W
2013-Sep-20 15:52 UTC
[R] Is there a way to change x and y axis tick mark inside plot()?
Dear R community, I am having trouble changing the tick marks on y-axis to every 5 units? I have the following: x <- c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8) y <- c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27) plot(x, y, pch=19) Should I change ylim=c(0,40), and then use axis()? I kept on thinking I can do everything inside plot(), but there is actually axis(), par(), ..., and so on. Could someone tell me why is there so many functions outside plot(). I'm sure there is a reason, but I don't seem to understand why. Thanks, Mike [[alternative HTML version deleted]]
Duncan Murdoch
2013-Sep-20 16:17 UTC
[R] Is there a way to change x and y axis tick mark inside plot()?
On 20/09/2013 11:52 AM, C W wrote:> Dear R community, > I am having trouble changing the tick marks on y-axis to every 5 units? I > have the following: > > x <- c(12, 16, 6, 23, 27, 8, 5, 19, 23, 13, 16, 8) > > y <- c(29, 29, 23, 34, 38, 24, 22, 34, 36, 27, 33, 27) > > plot(x, y, pch=19) > > Should I change ylim=c(0,40), and then use axis()?Don't use ylim, use yaxt="n", then use axis().> > I kept on thinking I can do everything inside plot(), but there is actually > axis(), par(), ..., and so on. > Could someone tell me why is there so many functions outside plot(). I'm > sure there is a reason, but I don't seem to understand why.R is designed to be flexible. If you create giant functions that can do everything, you end up with a design like SAS, which is extremely inflexible. It's good at what it can do, but it's very hard to get it to do something the designers didn't think of. Duncan Murdoch