roleic wrote:
> Thanks Jason,
> now I tried to implement such a True/False function in order to
> multiply it with the actual plot function to carve out the wanted plot
> region.
> Below I defined the function as a callable object as requested by the
> plot command.
> In a print test the function works well.
> But when used in the plot3d function all I get is a flat plane at +1
> height instead of a carved out rectangle at height +1 and a frame
> around it at 0 height.
> What is wrong? Is f in plot3d not evaluated for each set of
> parameters?
> roleic
> 
> ########################
> class plotregion:
>     def __init__(self):
>         pass
>     def __call__(self,u,v,umin,umax,vmin,vmax):
>         self.u,self.v,self.umin,self.umax,self.vmin,self.vmax =
> u,v,umin,umax,vmin,vmax
>         if (self.u < self.umin or self.u > self.umax or self.v <
> self.vmin or self.v > self.vmax):
>             return 0
>         else:
>             return 1
> ########################
> g = plotregion()
> for i in range(7):
>     for j in range(7):
>         print g(i,j,1,6-j,1,5),
>     print
> ########################
> f = plotregion()
> plot3d(f(u,v,1,4,1,3),(u,-2,6),(v,-2,6))
> ########################


You are evaluating the function before plotting it.  You need to do 
something like:

class plotregion:
     def __init__(self, umin, umax, vmin, vmax):
         self.umin, self.umax,self.vmin,self.vmax = umin,umax,vmin,vmax
     def __call__(self,u,v):
          if (u < self.umin or u > self.umax or v <
  self.vmin or v > self.vmax):
              return 0
          else:
              return 1

f=plotregion()
plot3d(f, (-2,6), (-2,6))

Jason


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to