[R] Help with filled.contour()

Michael Kubovy kubovy at virginia.edu
Mon Jan 1 20:47:55 CET 2007


On Jan 1, 2007, at 2:13 PM, Dieter Menne wrote:

> Michael Kubovy <kubovy <at> virginia.edu> writes:
>
>>
>> The following plot is a first approximation to what I need:
> .. see below
>
>> ***********************************
>> It has four drawbacks. I would like:
>> (1) to remove the white grid;
>> (2) to remove the white contours;
>> (3) its appearance to be smooth;
>> (4) to remove the key.
>
>
> In partial fulfillment of your requirements, increasing the levels  
> gives a nice
> smooth plot.
>
> mu1 <- 0
> mu2 <- 5
> s <- 1
> x <- seq(-2.5, 7.5, length = 41)
> y <- seq(-2.5, 2.5, length = 41)
> 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)))
> }
>
> z <- outer(x, y, f)
> persp(x, y, z)
> require(grDevices)
> filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1,
>      col = palette(gray(seq(0, 0.9, len = 500))), nlevels = 500)

Thanks, Dieter.

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

*********************************
Session Info
*********************************
 > sessionInfo()
R version 2.4.1 (2006-12-18)
powerpc-apple-darwin8.8.0

locale:
C

attached base packages:
[1] "datasets"  "grid"      "graphics"  "grDevices" "stats"      
"utils"     "methods"
[8] "base"

other attached packages:
          JGR       iplots       JavaGD         MASS      
gridBase      lattice
     "1.4-14"      "1.0-5"      "0.3-5"     "7.2-30"      "0.4-3"     
"0.14-16"
latticeExtra        rJava       xtable
      "0.1-4"     "0.4-12"      "1.4-2"

_____________________________
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