Thank you very much!
I'm using  par(new = TRUE)  because in my real case, the 2 plots have 
different ylim (different y-scale).
I got what I wanted by using the same xlim in the barplot and in the 
plot, as suggested by Peter.

My real case:

par(mar= c(7, 4, 5, 5) + 0.1)
area   <- c(136, 3426, 5594, 29268, 19080, 31461, 72629, 225443)/ 10000
nfires <- c(48, 134, 80, 131, 27, 24, 23, 14)

t <- barplot(area, xlim=c(0.5,9.5), ylim=c(0, 25), ylab="Area burnt (x 
1000 ha)", xlab="Fire size class")
box()
par(new= T, yaxs = "i", xpd=TRUE)
plot(t, nfires, type="o", xlim=c(0.5,9.5), pch=19, ylim=c(0, 140), 
axes=F, xlab="", ylab="")
axis(4); mtext("Number of fires", side=4, line=3, col=1)
legend(2, 155, "Number", lty= 1, pch= 19, bty="n", cex=0.8)
legend(2, 163, "    Area", fill= 2, bty="n", cex=0.8)


Cheers

Juli


Martin Maechler wrote:

>>>>>>"juli" == juli g pausas <[EMAIL PROTECTED]>
>>>>>>    on Thu, 18 Dec 2003 10:54:08 +0100 writes:
>>>>>>            
>>>>>>
>
>    juli> Dear colleges,
>    juli> I'm trying to combine a barplot and a plot in a single figure as follows:
>
>    juli> data <- 1:6
>    juli> t <- barplot(data, axes=F)
>    juli> par(new= T)
>    juli> plot(t, data, type="b")
>
>    juli> However, as you can see in the example, the dots of
>    juli> the second plot do not fall in the midpoint of the
>    juli> bars in the first. Any trick for setting the 2 plots
>    juli> at the same scale?
>
>yes, use
>
>   bd <- barplot(data)
>   points(bd, data, type = "b")
>
>instead.  
>A general recommendation: 
>   Try to *not* use par(new = TRUE) if you can.
>
>Martin
>
>  
>

-- 
Juli G. Pausas
Centro de Estudios Ambientales del Mediterraneo (CEAM)
C/ Charles R. Darwin 14, Parc Tecnologic,
46980 Paterna, Valencia, SPAIN
Tel: (+ 34) 96 131 8227; Fax: (+ 34) 96 131 8190
mailto:[EMAIL PROTECTED]
http://www.gva.es/ceam

GCTE Fire Network - http://www.gva.es/ceam/FireNetwork


        [[alternative HTML version deleted]]

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to