[R] image.plot transparent?

Peter Ehlers ehlers at ucalgary.ca
Fri Jul 13 23:51:50 CEST 2012


On 2012-07-13 06:07, Chris82 wrote:
> Hello,
>
> hiere is a small reproducible example.
>
> All z.i which are NA should be transparent at the plot, but they are white
> colored.
>
>
> ### Example image.plot regular x,y grid ###
>
> x <- seq(2,2.9,0.1)
> y <- seq(42,42.9,0.1)
>
> z <- matrix(seq(-5,4.9,0.1),nrow=10)
>
> image.plot(x,y,z)
>
>
> ### overplotting by a irregular grid ####
>
> x.i <-
> matrix(c(2.434842,2.436714,2.438593,2.440477,2.442368,2.472929,2.474831,2.476739,2.478654,2.480574,2.511019,2.512950,2.514888,2.516832,2.518782,2.549111,2.551072,2.553039,2.555012,2.556992,2.587205,2.589195,2.591192,2.593195,2.595204),nrow=5,byrow=T)
> y.i <-
> matrix(c(42.24368,42.28684,42.33005,42.37330,42.41660,42.24392,42.28708,42.33028,42.37354,42.41683,42.24415,42.28732,42.33052,42.37378,42.41707,42.24439,42.28756,42.33076,42.37402,42.41732,42.24464,42.28780,42.33101,42.37426,42.41756),nrow=5,byrow=T)
>
>
> z.i <- matrix(seq(-10,14,1),nrow=5)
>
> z.i[z.i< 0] <- NA
>
> image.plot(x.i,y.i,z.i, col=terrain.colors(20),add=T)

You still haven't told us what package you're using but,
like Professor Ripley, I assume that it's the fields package.
I believe that package uses a default of "white" for
missing values. You can reset that with the argument
'transparent.color' as in:

  image.plot(x.i,y.i,z.i, col=terrain.colors(20), add=TRUE,
             transparent.color = "transparent")

Peter Ehlers

>
> --
> View this message in context: http://r.789695.n4.nabble.com/image-plot-transparent-tp4635976p4636434.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list