Hi Eliza, I think you only need to change the margins and the placement of the right axis label:
colours <- c("black", "grey") par(mar=c(5,4,4,4)) barplot(prop,ylab = "Numbers", cex.lab = 1.5, cex.main = 1.4, beside=TRUE, col=colours,ylim=c(0,250)) axis(side=3,xlim=c(0,45), at=c(6,12,18,24,30,36,42), labels=c("Gd","Mu","Bg","Gk","Mn","Rw","Kh")) axis(side=3,xlim=c(0,45), at=c(6,12,18,24,30,36,42), labels=c("Gd","Mu","Bg","Gk","Mn","Rw","Kh")) par(new=TRUE) barplot(ELE, pch=15, xlab="", ylab="", axes=FALSE, type="b", col="red",yaxt = "n", ylim = rev(c(0,4500))) mtext("Cell Density",side=4,col="red",line=3) axis(4, ylim=c(0,7000), col="red",col.axis="red", las=1,cex.lab=0.5,cex.axis=0.7) Jim On Wed, Mar 23, 2016 at 4:17 AM, Eliza Botto <eliza_bo...@outlook.com> wrote: > Dear useRs, > I have defined two matrices "prop" and "ELE" in the following manner >> dput(prop) > structure(c(122.466666666667, 87.1500875, 94.3647755102041, 84.8471625, > 95.2767755102041, 84.15558125, 121.846666666667, 90.75970625, > 98.2028979591837, 87.1500875, 88.2953043478261, 72.81219375, 88.234, > 85.73326875, 82.4549743589744, 82.6041125, 96.1123888888889, 62.77575625, > 86.9222790697674, 64.74370625, 57.2601860465116, 58.98126875, > 91.7883555555556, 84.8471625, 92.170347826087, 84.15558125, 91.398085106383, > 91.79875, 108.423025641026, 72.81219375), .Dim = c(2L, 15L), .Dimnames = > list(c("ori", "sat"), c("Ba", "Gd", "Ko", "Mu", "Mz", "Bg", "Do", "Gk", "Ka", > "Mn", "Na", "Rw", "Rb", "Kh", "Sk"))) >> dput(ELE) > c(995.4, 813.5, 614, 2291, 702, 1038, 2571, 461, 700, 171, 2500, 1615, 587, > 1209, 1981) > Then I gave the following commands to make a plot > colours <- c("black", "grey") > barplot(prop,ylab = "Numbers", cex.lab = 1.5, cex.main = 1.4, beside=TRUE, > col=colours,ylim=c(0,250)) > axis(side=3,xlim=c(0,45), at=c(6,12,18,24,30,36,42), > labels=c("Gd","Mu","Bg","Gk","Mn","Rw","Kh")) > axis(side=3,xlim=c(0,45), at=c(6,12,18,24,30,36,42), > labels=c("Gd","Mu","Bg","Gk","Mn","Rw","Kh")) > par(new=TRUE) > barplot(ELE, pch=15, xlab="", ylab="", > axes=FALSE, type="b", col="red",yaxt = "n",ylim = rev(c(0,4500))) > mtext("Cell Density",side=4,col="red",line=1) > axis(4, ylim=c(0,7000), > col="red",col.axis="red",las=1,cex.lab=0.5,cex.axis=0.7) > The problem is that the second Y-axis is somewhat located outside the plot > and not visible. I kindly, require your help on it. > Thanks in advance, > Eliza > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.