Skip to content

Changing colour gradient in Spatstat surface plot

4 messages · Mulholland, Tom, PUJAN RAJ REGMI, Roger Bivand +1 more

#
# Rogers suggestion was 

library(RColorBrewer)
bl5 <- brewer.pal(5, "Blues")
mypal <- colorRampPalette(bl5)

# but he was saying any method of getting a list of colours is OK
rev(mypal(256))
rainbow(256)
colorRampPalette(c("lightblue","navy"))(256)

# then your example
       library(spatstat)
       data(longleaf)
       Z <- smooth.ppp(longleaf)
       par(mfrow = c(2,2))
       plot(Z)
       plot(Z, col=rev(mypal(256))) 
       plot(Z, col = colorRampPalette(c("lightblue","navy"))(256))  
       plot(Z, col = rainbow(256)) 

When Roger noted they were hard-coded he meant that the function
topo.colors and others are standard. Adrian was just pointing out that
his function is not hard coded to those functions and that you can use
any other function.

Tom

-----Original Message-----
From: r-sig-geo-bounces at stat.math.ethz.ch
[mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Graham Smith
Sent: Wednesday, 30 April 2008 3:00 AM
To: r-sig-geo at stat.math.ethz.ch
Subject: Re: [R-sig-Geo] Changing colour gradient in Spatstat surface
plot

Adrian

Thanks for the reply
This is what I did, but I couldn't find, and still can't find,   
anything in the help for plot.im or topo,colors that explains how to
change the colours to graduated blue, am  being really dim here.

However, in another post it was suggested I use rColorbrewer to set up
the colours , but it worries me that I cannot find the bit in the help
you have sent me to.

Graham

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
#
On Thu, 1 May 2008, PUJAN RAJ REGMI wrote:

            
I think that a few more details might help. This example uses methods from 
the sp package. Setup:

library(sp)
data(meuse.grid)
coordinates(meuse.grid) <- c("x", "y")
gridded(meuse.grid) <- TRUE

With lattice graphics:

l1 <- list("SpatialPolygonsRescale", layout.scale.bar(),
  offset = c(180500,329800), scale = 500, fill=c("transparent","black"))
l2 = list("sp.text", c(180500,329900), "0")
l3 = list("sp.text", c(181000,329900), "500 m")
spplot(meuse.grid, "dist", col.regions=grey.colors(20),
  sp.layout=list(l1, l2, l3))

With base graphics:

image(meuse.grid, "dist", col=grey.colors(20))
SpatialPolygonsRescale(layout.scale.bar(), offset = c(180500, 329800),
  scale = 500, fill=c("transparent","black"), plot.grid=FALSE)
text(180500, 329900, "0")
text(181000, 329900, "500 m")

layout.scale.bar() can take an argument setting the height of the scale 
bar, relative to the initial length of unity.

If this doesn't help, could you give an example of your problem using this 
or another accessible data set?

Roger