Message-ID: <200402052300.i15N0EW13309@gator.dt.uh.edu>
Date: 2004-02-05T23:00:14Z
From: Erin Hodgess
Subject: Plotting question
Hi Felix:
How about this:
> n1.Plot
function(x,my=0,sigma=1) {
f.x <- dnorm(x,mean=my,sd=sigma)
plot(x,f.x,type="l",xlim=c(-5,5))
return(f.x)
}
Hope this helps!
Sincerely,
Erin Hodgess
mailto: hodgess at gator.uhd.edu
i have written this little function to draw different normal distributions:
n.Plot <- function(x,my,sigma) {
e <- exp(1)
names(x) <- x
f.x <- (1/(sigma*sqrt(2*pi)))*e^(-1*(((x-my)^2)/2*(sigma^2)))
plot(f.x,type="l",xlim=c(-5,5))
return(f.x)
}
if i define x like this:
x <- seq(-5,5,0.01)
Now
n.Plot(x,0,1)
DOES draw the correct plot, but the x-axis is labeled from 0 - 1000.
If i give the plot function the xlim=c(-5,5) option, the plot is only drawn
for the first 5 values of x.
How do i tell plot not to take the indices of x, but the values (or their
range) of x for labeling the x-axis ?
Felix Eschenburg