Re: [R] plot question, increasing Y-axis labels

From: Joshua Wiley <jwiley.psych_at_gmail.com>
Date: Thu, 10 Mar 2011 10:28:58 -0800

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/

______________________________________________
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.
Received on Thu 10 Mar 2011 - 18:31:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 10 Mar 2011 - 19:00:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive