Re: [R] matching two plots

From: Romain Francois <francoisromain_at_free.fr>
Date: Thu 20 Oct 2005 - 05:46:07 EST

Le 19.10.2005 19:27, Rui Cardoso a écrit :

>Hi,
>
>I have a problem about graphics. I would like to plot two graphs: a barplot
>and curve. Here is the code:
>
> > barplot(dpois(0:45,20),xlim=c(0,45),names=0:45)
> > curve(dnorm(x,20,sqrt(20)),from=0,to=45,add=T)
>
>Both graphs are drawn in the same figure, however the scale in both graphs
>dooes not match. For some reason the second plot is shifted to left. I
>think there is a problem concerning the axis scale.
>
>Thanks a lot.
>
>Rui
>
>
Hello,

The problem is barplot. To see that :

R> (barplot(dpois(0:45,20),xlim=c(0,45),names=0:45)) R> axis(3)

Try something like :

R> plot(0:45, dpois(0:45,20), type="h", lwd=4, col="gray") R> curve(dnorm(x,20,sqrt(20)),from=0,to=45,add=T)

Romain

-- 
visit the R Graph Gallery : http://addictedtor.free.fr/graphiques
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
~~~~~~      Romain FRANCOIS - http://francoisromain.free.fr      ~~~~~~
~~~~~~~~           Doctorant INRIA Futurs / EDF                ~~~~~~~~
~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Thu Oct 20 05:45:18 2005

This archive was generated by hypermail 2.1.8 : Sun 23 Oct 2005 - 19:07:12 EST