mohan.radhakrishnan at polarisft.com
2013-Nov-04 09:54 UTC
[R] All curves with same y-axis scale
Hi, When I plot 3 curves with the same x-axis and same y-axis, the first two curves honor the y-axis but the last one doesn't. When I remove yaxt="n" for the last curve a new scale appears on the y-axis along with the scales that the first two curves use. I want all curves to use the same y-axis scale. What is missing ? Init Used Committed Max Time 1 2359296 13913536 13959168 50331648 200 2 2359296 13915200 13959168 50331648 400 3 2359296 13947712 13991936 50331648 600 4 2359296 13956224 13991936 50331648 800 5 2359296 13968832 14024704 50331648 1000 6 2359296 13978048 14024704 50331648 1200 7 2359296 14012416 14090240 50331648 1400 8 2359296 14450304 14548992 50331648 1600 9 2359296 14521024 14548992 50331648 1800 10 2359296 14536320 14548992 50331648 2000 11 2359296 14553344 14581760 50331648 2200 plot(data$Time,as.numeric(data$Used),col="green",pch=16,type="b", ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1) axis(1,at = seq(min(data$Time), max(data$Time), by=1000),las = 2,cex.axis=1) title("Time vs Used Code cache,Committed and Maximum Code cache",cex.main=1.5,xlab="Time(Seconds)") par(new=T) plot(data$Time,as.numeric(data$Committed),col="orangered",pch=16,type="b", ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1,yaxt="n") par(new=T) plot(data$Time,as.numeric(data$Max),col="palevioletred3",pch=16,type="b", ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1,yaxt="n") Mohan This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com [[alternative HTML version deleted]]
On 11/04/2013 08:54 PM, mohan.radhakrishnan at polarisft.com wrote:> Hi, > > When I plot 3 curves with the same x-axis and same y-axis, the first two > curves honor the y-axis but the last one doesn't. When I remove yaxt="n" > for the last curve a new scale appears on the y-axis along with the scales > that the first two curves use. I want all curves to use the same y-axis > scale. > > What is missing ? > > Init Used Committed Max Time > 1 2359296 13913536 13959168 50331648 200 > 2 2359296 13915200 13959168 50331648 400 > 3 2359296 13947712 13991936 50331648 600 > 4 2359296 13956224 13991936 50331648 800 > 5 2359296 13968832 14024704 50331648 1000 > 6 2359296 13978048 14024704 50331648 1200 > 7 2359296 14012416 14090240 50331648 1400 > 8 2359296 14450304 14548992 50331648 1600 > 9 2359296 14521024 14548992 50331648 1800 > 10 2359296 14536320 14548992 50331648 2000 > 11 2359296 14553344 14581760 50331648 2200 > > plot(data$Time,as.numeric(data$Used),col="green",pch=16,type="b", > ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1) > axis(1,at = seq(min(data$Time), max(data$Time), by=1000),las > 2,cex.axis=1) > title("Time vs Used Code cache,Committed and Maximum Code > cache",cex.main=1.5,xlab="Time(Seconds)") > > par(new=T) > plot(data$Time,as.numeric(data$Committed),col="orangered",pch=16,type="b", > ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", > cex.lab=1.2,cex.axis=1,yaxt="n") > > par(new=T) > plot(data$Time,as.numeric(data$Max),col="palevioletred3",pch=16,type="b", > ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", > cex.lab=1.2,cex.axis=1,yaxt="n") >Hi Mohan, This is because the ranges of "Used" and "Committed" are so close that you probably didn't notice the difference. "Max" is just a straight line way off the two original plots. If you want to show these three widely varying values on the same plot, use the lines or points function for the second two sets of values and set your ylim in the first plot to contain all the values to be plotted. You might also look at the gap.plot function in plotrix if you want to avoid two lines at the bottom of the plot and one line right at the top: gap.plot(data$Time,data$Used,gap=c(15000000,49000000), ylim=c(13500000,50500000),type="b",pch="U") gap.plot(data$Time,data$Committed,gap=c(15000000,49000000), type="b",pch="C",add=TRUE) gap.plot(data$Time,data$Max,gap=c(15000000,49000000), type="b",pch="M",add=TRUE) Jim
mohan.radhakrishnan at polarisft.com
2013-Nov-05 10:31 UTC
[R] All curves with same y-axis scale
Hi Jim, I am using this code and it is working well. I convert everything to MB. I may not fully understand "levels(data$Used)[data$Used])" but I use it everywhere and it works. data$Used <- as.numeric(levels(data$Used)[data$Used])/(1024*1000) data$Committed <- as.numeric(levels(data$Committed)[data$Committed])/(1024*1000) data$Max<- as.numeric(levels(data$Max)[data$Max])/(1024*1000) print(data) png( "code-cache.png", width =1200, height = 500) plot(data$Time,as.numeric(data$Used),ylim=c(1,60),col="orangered",pch=2,type="b", ylab="Megabytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1.2) axis(1,at = seq(min(data$Time), max(data$Time), by=1000),las = 2,cex.axis=1) title("Time vs Used Code cache,Committed and Maximum Code cache",cex.main=1.5,xlab="Time(Every 200 Seconds)") points(data$Time,as.numeric(data$Committed),col="grey",pch=3,lwd=2, cex.lab=1.2,cex.axis=1,type="b") points(data$Time,as.numeric(data$Max),col="palevioletred3",pch=16,lwd=2, cex.lab=1.2,cex.axis=1,type="b") dev.off() Thanks, Mohan From: Jim Lemon <jim@bitwrit.com.au> To: mohan.radhakrishnan@polarisft.com Date: 11/05/2013 03:47 AM Subject: Re: [R] All curves with same y-axis scale On 11/04/2013 11:04 PM, mohan.radhakrishnan@polarisft.com wrote:> Hi, > > I changed the code. The first two curves seem to plot properly without > the 'ylim'. 'ylim' doesn't allow the first two curves to plot properly. > It doesn't have any effect on the 3rd curve. > >plot(data$Time,as.numeric(data$Used),ylim=c(min(as.numeric(data$Used)),max(data$Max)),col="green",pch=16,type="b",> ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n",cex.lab=1.2,cex.axis=1.2)> axis(1,at = seq(min(data$Time), max(data$Time), by=1000),las > 2,cex.axis=1) >Hi Mohan, Looks like it's doing what you ask of it to me. data<-read.table(text="Init Used Committed Max Time 2359296 13913536 13959168 50331648 200 2359296 13915200 13959168 50331648 400 2359296 13947712 13991936 50331648 600 2359296 13956224 13991936 50331648 800 2359296 13968832 14024704 50331648 1000 2359296 13978048 14024704 50331648 1200 2359296 14012416 14090240 50331648 1400 2359296 14450304 14548992 50331648 1600 2359296 14521024 14548992 50331648 1800 2359296 14536320 14548992 50331648 2000 2359296 14553344 14581760 50331648 2200",header=TRUE) png("mk.png") plot(data$Time,as.numeric(data$Used) ,ylim=c(min(as.numeric(data$Used)),max(data$Max)), col="green",pch=16,type="b", ylab="MegaBytes", xlab="",las=2,lwd=2,xaxt="n", cex.lab=1.2,cex.axis=1.2) axis(1,at = seq(min(data$Time), max(data$Time), by=1000),las = 2,cex.axis=1) title( "Time vs Used Code cache,Committed and Maximum Code cache", cex.main=1.5,xlab="Time(Every 200 Seconds)") points(data$Time,as.numeric(data$Committed), col="orangered",pch=16,lwd=2, cex.lab=1.2,cex.axis=1,type="b") points(data$Time,as.numeric(data$Max), col="palevioletred3",pch=16,lwd=2, cex.lab=1.2,cex.axis=1,type="b") dev.off() Jim [attachment "mk.png" deleted by Mohan Radhakrishnan/BSC31/polarisFT] This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit us at http://www.polarisFT.com [[alternative HTML version deleted]]