R contour levels don't match filled.contour -
hopefully straightforward question made simple figure in r using filled.contour(). looks fine, , should given data. however, want add reference line along contour 0 (level = 0), , plotted line doesn't match colors on filled.contour figure. line close, not matching figure (and crossing on contour filled.contour plot). ideas why happening?
aa <- c(0.05843150, 0.11300040, 0.15280030, 0.183524400, 0.20772430, 0.228121000) bb <- c(0.01561055, 0.06520635, 0.10196237, 0.130127650, 0.15314544, 0.172292410) cc <- c(-0.02166599, 0.02306650, 0.05619421, 0.082193680, 0.10334837, 0.121156780) dd <- c(-0.05356592, -0.01432910, 0.01546647, 0.039156660, 0.05858709, 0.074953650) ee <- c(-0.08071987, -0.04654243, -0.02011676, 0.000977798, 0.01855881, 0.033651089) ff <- c(-0.10343798, -0.07416114, -0.05111547, -0.032481132, -0.01683215, -0.003636035) gg <- c(-0.12237798, -0.09753544, -0.07785126, -0.061607548, -0.04788856, -0.036169540) hh <-rbind(aa,bb,cc,dd,ee,ff,gg) z <- as.matrix(hh) y <- seq(0.5,1.75,0.25) x <- seq(1,2.5,0.25) filled.contour(x,y,z, key.title = title(main=expression("log"(lambda))), color.palette = topo.colors) #this works contour(x,y,z, level=0,add=t,lwd=3) #this line doesn't match plot
this answered in ?filled.contour
page. in notes section states
the output produced filled.contour combination of 2 plots; 1 filled contour , 1 legend. 2 separate coordinate systems set these 2 plots, used internally – once function has returned these coordinate systems lost. if want annotate main contour plot, example add points, can specify graphics commands in plot.axes argument. see examples.
and examples given in page show how annotate on top of main plot. in particular case, correct way be
filled.contour(x,y,z, key.title = title(main=expression("log"(lambda))), color.palette = topo.colors, plot.axes = { axis(1) axis(2) contour(x,y,z, level=0,add=t,lwd=3) } )
which produces
Comments
Post a Comment