[R] plot question, increasing Y-axis labels

Joshua Wiley jwiley.psych at gmail.com
Thu Mar 10 19:28:58 CET 2011


Hi Mike,

You can use the ?axis function to add custom axes in.  To prevent
overwriting, you will want to suppress the default y axis in your call
to plot.  You can find details on the arguments and parameters in ?par
(I recommend pulling it up in a way that you can search because the
par documentation is very long though very useful).

Here is an example:

## something like what you might have
plot(1:25, 1:25, ylim = c(5, 25))

## plot suppressing the axis
plot(1:25, 1:25, ylim = c(5, 25), yaxt = "n")
## add axis with your own breaks/labels
axis(side = 2, at = 5:25)


Cheers,

Josh

On Thu, Mar 10, 2011 at 10:08 AM, Mike Gibson <megalops31 at hotmail.com> wrote:
>
> I want to increase the number of labels on my y-axis.  Here is my code:
>
>  plot(fish$species, fish$fl, ylim=c(5,25), xlab="Species", ylab="Fork Length (in)")
>
> The plot is great but it only has numerical y-labes every five values (i.e. labels at 5, 10, 15, and 25).   I want R to give me the same plot but a y-axis label at every integer (i.e. labels at 5,6,7,8,9,10,...25).
>
> I have been unable to figure this out.  Any adice would be greatly appreciated.
>
> Mike
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list