I want to draw horizontal and vertical lines on my level plot corresponding to x values from 74 to 76 and y values from 28 to 32. Below is my R code. But when I run the following,I get the levelplots but no lines. I also recieve no error from R. The default theme on my installation is something which maps the values to pink and cyan. I have also tried using the panel function but no luck with that as well.
levelplot(d_fire_count_nom ~ longitude + latitude | factor(day)+factor(year),
data = asia,
subset = (month == 10), aspect="iso", contour = FALSE, layout=c(1,1),
main="If a fire occured in a region (low confidence) in October during 2001-2008",
scales=list(x=list(at=seq(from=60,to=98, by=1)),
y=list(at=seq(from=5,to=38,by=1)),cex=.7, alternating=3),
xlim=c(60, 98), ylim=c(5, 38),
abline=list(h=74:76, v=28:32, col="grey"))
That's not how
lattice
graphics work. In fact, if you read?levelplot
you'll see that there is no argument to that function calledabline
, so I'm not sure where you got that syntax from.You add things to
lattice
graphics by altering thepanel
function. There are manypanel.*
functions for doing various things, like plotting points, lines, scatterplot smoothers, etc. In this case there's apanel.abline
that we'd like to use. So we define our ownpanel
function.This uses the very first example from
?levelplot
:Our new panel function needs to first draw the levelplot, so we have it call
panel.levelplot
first. Then we want to add some lines, so we addpanel.abline
for that purpose.