On 01/19/2013 01:26 PM, Jd Devkota 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.
try:
library(fortunes)
fortune("there is no if")
Reflecting on that, it would involve a bit of programming, essentially
writing an appropriate panel function for lattice::levelplot. I did this
back then for polygons, found in sp:::panel.polygonsplot, which is 80
lines of R code. My guess is that it should be considerable more easy
for points. I'd be happy to receive & consider proposals.
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 <-
Error in spplot(data1, sp.layout = list(list("sp.polygons", hello), l2, :
error in evaluating the argument 'obj' in selecting a method for
function 'spplot': Error: object 'data1' not found
We don't have data1, so we can't see what you mean.
Please provide an example that, when copy and pasted, simply runs. This
means: include a library(sp), and import and use a data set available in
a package, such as the meuse data.
Thank you so much.
Janesh
[[alternative HTML version deleted]]