# [R] how do R calculates the number of intervals between tick-marks

Antonio Olinto aolinto_r at bignet.com.br
Wed Aug 25 20:49:43 CEST 2010

```Hi,

With axTicks I did what I wanted. Thank you all for the attention.

Below is the code I did to have a plot with three y axes.

Suggestions to improve the routine are welcome.

All the best,

Antonio Olinto

YEAR	L	NFB	NFT
2005	26,352158	1500	25,014
2006	32,514789	2100	35,024
2007	27,458126	1800	30,254
2008	28,568971	1500	43,254
2009	32,564789	3000	60,32

# comma is a decimal symbol

attach(dat.lnbnt)
summary(dat.lnbnt)
YEAR            L              NFB            NFT
Min.   :2005   Min.   :26.35   Min.   :1500   Min.   :25.01
1st Qu.:2006   1st Qu.:27.46   1st Qu.:1500   1st Qu.:30.25
Median :2007   Median :28.57   Median :1800   Median :35.02
Mean   :2007   Mean   :29.49   Mean   :1980   Mean   :38.77
3rd Qu.:2008   3rd Qu.:32.51   3rd Qu.:2100   3rd Qu.:43.25
Max.   :2009   Max.   :32.56   Max.   :3000   Max.   :60.32

y1min <- 26
y1max <- 33
y1range <- y1max-y1min
y2min <- 1500
y2max <- 3000
y2range <- y2max-y2min
y3min <- 25
y3max <- 61
y3range <- y3max-y3min

par(mar=c(6, 6, 2,12))
plot(L, ylim=c(y1min,y1max), ylab="landings (×1000 t)",
type="l",col="red",las=0, cex.axis=1.2,cex.lab=1.4,xaxt="n",xlab="")
points(y1range*((NFB-y2min)/y2range)+y1min,type="l",col="blue")
points(y1range*((NFT-y3min)/y3range)+y1min,type="l",col="darkgreen")

yticks <- axTicks(2)
interval <- yticks[2]-yticks[1]
divisions <- length(yticks)-1

axis(1,at=axTicks(1),labels=as.character(YEAR),las=2,cex.axis=1.2)
axis(4,at=seq(y1min,y1max,interval),labels=as.integer(seq(y2min,y2max,y2range/divisions)),las=0,cex.axis=1.2)
axis(4,at=seq(y1min,y1max,interval),labels=as.integer(seq(y3min,y3max,y3range/divisions)),cex.axis=1.2,
las=0,line=5)
mtext("nº of fishing boats",4,3,cex=1.4)
mtext("nº of fishing trips (×1000)",4,8, cex=1.4)
legend(4,33,c("L","Nº FB","Nº
FT"),bty="n",lty=c(1,1,1),col=c("red","blue","darkgreen"),cex=1.4)

Citando David Winsemius <dwinsemius em comcast.net>:

>
> On Aug 24, 2010, at 7:05 PM, Antonio Olinto wrote:
>
>> Hello,
>>
>> I want to know how do R calculates the number of intervals between
>> tick-marks in the y axis in a plot.
>
> ?axTicks # and then look at the other citations and the code as needed
>
>
>>
>> I'm making a three y-axes plot and this information would help me a lot.
>>
>>
>> Antonio Olinto
>>
> --
>
> David Winsemius, MD
> West Hartford, CT
>
>

----------------------------------------------------------------
Webmail - iBCMG Internet
http://www.ibcmg.com.br

```