MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Stack graphics



Marcia,

I hope you get simpler answers than this, but here's one way to 
accomplish what you want.  First create an "invisible" surface (note 
that it is invisible in the same way that a polar bear is invisible 
during a blizzard: you can't see it because it blends in with its 
background):

f[x_,t_]:=Exp[-(x-Cos[Pi t])^2]

s=Plot3D[f[x,t],{x,-5,5},{t,0,3},
PlotPoints->35,Boxed->False, Mesh->False, Shading->False];

If you want to check that it's really there, change the color of the 
snow:

Plot3D[f[x,t],{x,-5,5},{t,0,3},
PlotPoints->35,Boxed->False,Shading->False, Mesh->False, 
Background->Hue[.6]];

Now we create the curves you want.  We use Plot because it produces 
smoother curves than ParametricPlot3D; then we convert the curves to 
genuine 3D objects by first extracting the Line objects using Cases,
and  then applying a transformation rule to change the 2D-data into
3D.  The  z+epsilon is necessary to make sure none of the lines dip
below the  level of the surface.  You could use Mathematica to
calculate an  appropriate epsilon, or just use trial and error. 

epsilon=0.012;
gtab=Table[
              Cases[
                  InputForm[
                      Plot[f[x,t],{x,-5,5},DisplayFunction -> 
Identity]],
              _Line, Infinity]/.{x_Real, z_}:>{x,t,z+epsilon},
          {t, 0., 3, 3./34}];

Now show both graphics together:

Show[s, Graphics3D[gtab] ];


Of course, if you intended to use this kind of plot very often it would
 not be difficult to write a routine that would perform these steps
for  you.  Also note: you can color the surface any way you like (you
don't  have to make it match the background unless that is the effect
you're  looking for.)

Hope this helps,

Ron Goetz
rgoetz@mcmail.stlcc.cc.mo.us

-----Original Message-----
From: Marcia T. Fontenelle <fontenelle@atom.kth.se> To:
mathgroup@smc.vnet.net
Subject: [mg11711] [mg11632] Stack graphics


>I would like to plot a set of curves, say f[x,t], for several different
>t's, almost like a 3D plot, but with mesh just on t. More like
>StackGraphics does, but each curve should hide the ones on the back.
>
>Observe the following example and compare the two outputs
>
><<Graphics`Graphics3D`
>
>f[x_,t_]:=Exp[-(x-Cos[Pi t])^2]
>
>Plot3D[f[x,t],{x,-5,5},{t,0,3},
>PlotPoints->35,Boxed->False,Shading->False]
>
>** Here Mathematica draws a beautiful plot, with HiddenSurface->True,
>but the mesh is in both directions
>
>gtab=Table[Plot[f[x,t],{x,-5,5},DisplayFunction -> Identity], {t,
>0,3,0.2}];
>
>Show[StackGraphics[gtab],PlotRange->{0,1.1},Boxed->False]
>
>** Here StackGraphics produces mesh just in t, as wanted, but I cannot
>set HiddenSurface->True. The result is not adequate for my problem.
>(Just imagine something a little more complicated than Gaussian packets
>oscillating forth and back in time-it would be certainly too hard to
>visualize.)
>
>What would be the solution for this? Is there any option in Plot3D that
>I haven't seen yet?
>
>Best regards,
>
>Marcia
>
>--
>Marcia T. Fontenelle
>Laser Physics and Quantum Optics
>KTH - Royal Institute of Technology
>10044 Stockholm
>Sweden
>
>email: fontenelle@atom.kth.se
>www: http://bob.optics.kth.se/Members/Fontenelle
>
>




  • Prev by Date: Animation?
  • Next by Date: FixedPoint and SameTest
  • Prev by thread: Re: Stack graphics
  • Next by thread: Re: Stack graphics