[R] Scale of axis for two data sets

Jim Lemon jim at bitwrit.com.au
Tue Aug 27 11:37:11 CEST 2013


On 08/27/2013 05:58 PM, mohan.radhakrishnan at polarisft.com wrote:
> Hi,
>
> Kbytes                     RSS                         rNo
>
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1450876 1433788
> 2689632 1460168 1443084
>
>
>
> plot(data$rNo,data$RSS,pch=0,type="b",col=36,axes=FALSE,  ylab="",
> xlab="",las=2,lwd=2.5)
> title(" PID - 23512 / pmap Data Analysis for 1
> hour",cex.main=3,xlab="Seconds", ylab="Kbytes ", cex.lab=3,1)
>
> axis(side=1, at=seq(0, max(data$rNo), by=5), cex.axis=1.7)
> axis(side=2, at=seq(0, max(data$Kbytes ), by=1000), cex.axis=1.7)
>
> This code plots Kbytes against rNo.
>
> I tried to combine this with the plot of RSS against rNo. It looks like
> with the same scale in the y-axis(Kbytes) the second graph(RSS/rNo)
> doesn't show plots properly. It seems like the second plot draws properly
> but doesn't match the y-axis scale.
>
> IfI separate the plots into two 'R' files I get it correctly.
>
> How do I used the same y-axis scale(Kbytes) but also plot RSS against rNo.
> Hope I am not confusing this.
>
Hi Mohan,
I am somewhat confused, but you may want something like this:

mohan.dat<-read.table(text="Kbytes RSS rNo
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1450876 1493788
2689632 1460168 1453084",header=TRUE)
library(plotrix)
twoord.plot(lx="rNo",ly="Kbytes",rx="rNo",ry="RSS",data=mohan.dat)

However, the lack of variability in the Kbytes field revealed a bug in 
twoord.plot (thanks) which I have fixed, so if you want to plot data 
that has no variability you will have to wait for the next version of 
plotrix.

Jim



More information about the R-help mailing list