[R] Help with filled.contour()

Michael Kubovy kubovy at virginia.edu
Thu Jan 4 01:37:17 CET 2007


To Jeff: a tip of the hat.

I have another question after Jeff's solution:

On Jan 3, 2007, at 5:09 PM, Jeffrey Horner wrote:

> Michael Kubovy <kubovy <at> virginia.edu> writes:
>> I tried and it gave a strange result. See
>> http://people.virginia.edu/~mk9y/mySite/twoGaussian.R
>> and
>> http://people.virginia.edu/~mk9y/mySite/twoGaussian.pdf
>
>
> Try the image function. The smoothness of the plot will be  
> proportional to the length of x and y. For instance 200 isn't bad:
>
> mu1 <- 0
> mu2 <- 5
> s <- 1
> x <- seq(-2.5, 7.5, length = 200)
> y <- seq(-2.5, 2.5, length = 200)
> f <- function(x,y){
>     term1 <- 1/(2*pi*sqrt(s*s))
>     term2 <- -1/2
>     term3 <- (x - mu1)^2/s
>     term4 <- (y - mu1)^2/s
>     term5 <- (x - mu2)^2/s
>     term1*(.5 * exp(term2*(term3 + term4)) + .5 * exp(term2*(term5  
> + term4)))
> } # setting up the function of the multivariate normal density
> z <- outer(x, y, f)
> # persp(x, y, z)
> require(grDevices)
> #pdf('twoGaussian.pdf')
> #filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1,
> #               col = gray(seq(0, 0.9, len = 25)), nlevels = 25)
> image(x,y,z,col=gray(seq(0,0.9,len=200)))

Is there a simpler way to get rid of axes, frame, and axis labels than
image(x, y, z, col = gray(seq(0, 0.9, len = 200)), asp = 1, xaxt =  
'n', yaxt = 'n', bty = 'n', ann = F)
?

_____________________________
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS:     P.O.Box 400400    Charlottesville, VA 22904-4400
Parcels:    Room 102        Gilmer Hall
         McCormick Road    Charlottesville, VA 22903
Office:    B011    +1-434-982-4729
Lab:        B019    +1-434-982-4751
Fax:        +1-434-982-4766
WWW:    http://www.people.virginia.edu/~mk9y/



More information about the R-help mailing list