Jd Devkota
2013-Jan-19 12:16 UTC
[R] Is it possible to create color ramp legend in spplot for discontinuous data ?
Hello All,
I have a discontinuous dataset and I used spplot to plot the points.
I was wondering whether it is possible to show the legend of the plot as
color ramp. I saw that on continuous data. If anyone could tell me that
would be great.
Another thing I would like to know is how can we create the horizontal
legend. By default, the legend is vertical.
I was able to shift the legend inside the plot but not horizontal. Some of
the code I used is as follows:
##Polygon as major plot and contour as layout
## Put north icon on the map
l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset
c(439000,3368000), scale = 4000)
l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset
c(460000,3352000), scale = 5000,
fill=c("transparent","black"))
l4 = list("sp.text",c(460000,3351500),"0")
l5 = list("sp.text",c(465000,3351500),"100 m")
cuts=c(0,5,10,15,20,25,30,35,37,39,40)
p1 <-
spplot(data1,sp.layout=list(list("sp.polygons",hello),l2,l3,l4,l5),axes=T,xlab="Eastings",cuts=cuts,
ylab="Northings",lwd=2,cex=1.2,col.regions = rainbow(100, start =
3/15, end
= 1))
# Legend in Spplot
names(p1$legend) <- "inside"
p1$legend$inside$x <- 0.15
p1$legend$inside$y <- 0.9
plot(p1)
Thank you so much.
Janesh
[[alternative HTML version deleted]]
Ista Zahn
2013-Jan-20 02:38 UTC
[R] Is it possible to create color ramp legend in spplot for discontinuous data ?
Hi Janesh, I'm going to ask you the same thing you were asked when you posted this question on the r-sig-Geo list: What is data1? Please give us the output of dput(data1), or make another example that we can reproduce. Best, Ista On Sat, Jan 19, 2013 at 7:16 AM, Jd Devkota <janesh.devkota at gmail.com> wrote:> Hello All, > > I have a discontinuous dataset and I used spplot to plot the points. > > I was wondering whether it is possible to show the legend of the plot as > color ramp. I saw that on continuous data. If anyone could tell me that > would be great. > > Another thing I would like to know is how can we create the horizontal > legend. By default, the legend is vertical. > > I was able to shift the legend inside the plot but not horizontal. Some of > the code I used is as follows: > > ##Polygon as major plot and contour as layout > ## Put north icon on the map > l2 = list("SpatialPolygonsRescale", layout.north.arrow(), offset > c(439000,3368000), scale = 4000) > l3 = list("SpatialPolygonsRescale", layout.scale.bar(), offset > c(460000,3352000), scale = 5000, fill=c("transparent","black")) > l4 = list("sp.text",c(460000,3351500),"0") > l5 = list("sp.text",c(465000,3351500),"100 m") > cuts=c(0,5,10,15,20,25,30,35,37,39,40) > > p1 <- > spplot(data1,sp.layout=list(list("sp.polygons",hello),l2,l3,l4,l5),axes=T,xlab="Eastings",cuts=cuts, > ylab="Northings",lwd=2,cex=1.2,col.regions = rainbow(100, start = 3/15, end > = 1)) > > # Legend in Spplot > names(p1$legend) <- "inside" > p1$legend$inside$x <- 0.15 > p1$legend$inside$y <- 0.9 > plot(p1) > > Thank you so much. > > Janesh > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.