Skip to content
Prev 9403 / 15075 Next

Contour lines not plotting in correct position

On 12-10-24 10:42 PM, Thomas Veltman wrote:
You use a different definition for the x in the call to contour, i.e. 
seq(0,1,length.out=(nrow(Electrolyzer))), then you used when you 
computed it, i.e. seq(from=0.05,to=1, by=0.01).

A good practice is to compute the x and y vectors just once, and use the 
outer() function to compute the array.  You may need to use Vectorize() 
to make sure your function works properly in outer().  For example,

Electrolyzer <- outer(etaELEC, FE, function(x, y) 
Ecap(FE=y,etaST=0,etaFC=0,etaELEC=x,etaRP=0.6,etaCOMP=0.95,ENH3=340))

then use etaELEC and FE in the calls to contour.  I would also use 
"add=TRUE" in your calls to contour() if you want those plots overlaid: 
  that will work on any device, not just png():

contour(etaELEC, 
FE,Electrolyzer,axes=FALSE,levels=c(-0.1,0,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1), 
add=TRUE)
contour(etaELEC, 
FE,Electrolyzer,axes=FALSE,levels=c(0.102),col="red",add=TRUE)

Another good practice is to simplify your question as much as possible 
before posting it.  Often you'll discover your own error in the simple 
version, and won't need to post at all.

And finally, as David said, this sort of question should go to R-help, 
not R-sig-mac, unless you think there's something Mac-specific about the 
problem.  But posting a working example is much better than most "first 
posts"; thanks for doing that.

Duncan Murdoch