Hi Muhammad,

The problem is that you set the par() options before creating your png.
I've tried, and it works if you do this:
... # x and y
png("image.png")
par(mar=c(5,5,5,7)+0.1) # inner margin
par(oma=c(3,3,3,7))    # outer margin
... # rest of your code

HTH,
Ivan

Le 4/2/2010 12:12, Muhammad Rahiz a écrit :
Dear useRs,

I'm having a slight problem with plotting on 2 axes. While the following code works alright on screen, the saved output does not turn out as desired i.e. the secondary y-axis does not display fully.

Just run the code and look at image output. Suggestions please...

thanks,

Muhammad

---
rm(list=ls())
x <- 1:100
y <- 200:300

par(mar=c(5,5,5,7)+0.1) # inner margin
par(oma=c(3,3,3,7))    # outer margin
png("image.png")
plot(x,cex=0.5,type="l",lty=2,pch=3,xlab="year",ylab="x-axis",las=1,col="blue")
par(new=TRUE)
plot(y,cex=0.5,type="l",lty=2,pch=3,xlab="",ylab="",las=1,axes=FALSE,ylim=c(0,500),col="red")
axis(4,las=1)
mtext("y-axis",side=4,line=3)
legend("topleft",col=c("blue","red"),lty=2,legend=c("x","y"),bty="n")
box("figure",col="red")
box("plot",col="blue")
dev.off()

______________________________________________
R-help@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.


--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

______________________________________________
R-help@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.

Reply via email to