[R] reversing perspective plot axis

James jctoll at gmail.com
Wed Oct 31 03:17:17 CET 2007


Hi,

I am trying to create a perspective plot with Time on the x-axis,  
Underlying Price on the y-axis, and Option Price on the z-axis.  But  
I don't like the way my x-axis is setup.  Right now, Time is this  
sequence.

Time = seq(from = 1/52, to = 1, by=1/52)

That results in the x-axis going from 0 at the back, to 1 near the  
foreground corner.(If that makes any sense)  I want to do the exact  
opposite.  When I try this sequence:

Time = seq(from = 1, to = 1/52, by=-1/52)

I get this error message:

Error in persp.default(x = Time, y = S, z = Price, xlab = "Time",  
ylab = "S",  :
	increasing 'x' and 'y' values expected

So it seems that I can't use a descending sequence for my perspective  
plot.  Is that true?  Is there a way to work around this?

persp(x=Time, y=S, z=Price, xlab="Time", ylab="S", zlab=TypeFlag, ...)

Essentially, what I'm trying to create is something that looks like  
this.

http://www.insightful.com/products/finmetrics/opSensitivity1_lg.gif

You can see how Time on the x-axis diminishes as it moves to the  
foreground corner.

Thanks in advance.

James



More information about the R-help mailing list