[R] Plot contour over filled contour

S Ellison S.Ellison at lgc.co.uk
Fri Mar 14 12:14:09 CET 2008



>>> "Devred, Emmanuel" <DevredE at mar.dfo-mpo.gc.ca> 13/03/2008 18:08:45
>>>
Dear R-users,

>I haven't found a way in the searchable archive to overplot a contour
>(lines) over a surface.

I got round this by using the plot.axis parameter, which accepts a set
of plotting commands and isn't fussy about what. Since this is
implemented before the plot parameters are reset on return, it puts the
contours in the right places without hacking about with par() etc.

My example (from a response surface fit to some analytical chemistry
data) was 

filled.contour(x=HCl, y=HNO3, z=td.g, 
	plot.axes={axis(1);axis(2);contour(x=HCl, y=HNO3, z=td.g,
add=T)}, 
	color=rgb.palette, 
	main="Typical Diet", xlab="HCl (ml)", ylab="HNO3 (ml)")

In this example, HCl and HNO3 were the two independent variables and
td.g was the matrix of responses.
Note the call to contour(... add=T) inside plot.axes={}. rgb.palette
was just an alternative rainbow-like palette I'd defined using .






*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list