Re: Re: Plot3D with only x or y mesh?
- To: mathgroup at smc.vnet.net
- Subject: [mg9696] Re: [mg9636] Re: Plot3D with only x or y mesh?
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Fri, 21 Nov 1997 01:31:35 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Xah" <xah at best.com> [mg9636] Re: Plot3D with only x or y mesh? writes > In article <64e898$qgn at smc.vnet.net>, siegman at ee.stanford.edu (AES) >wrote: >>Can one make Plot3D plots with only x mesh lines, or only y mesh >>lines? > >Not with build-in functions or options, but you can do it easily >otherwise. Here's a solution. [solution copied below line ********************] Here is another way: it has the disadvantage that for this purpose lines are repeated and are in segments, but it seems quite flexible and preserves the options of the original Plot3D (apart from altering the mesh lines). plt = Plot3D[Sin[x*y],{x,0,Pi},{y,0,Pi},PlotPoints->{11,11},Mesh->False]; gr = Graphics3D[plt]; msh = gr/.Polygon[{a_,b_,c_,d_}]-> {Hue[.0],Line[{a,b}],Line[{c,d}], Hue[.7],Line[{b,c}],Line[{d,a}] }; Show[plt,msh] We can alter the code for msh to produce various results. Allan Hayes hay at haystack.demon.co.uk http://www.haystack.demon.co.uk/training.html voice:+44 (0)116 2714198 fax: +44 (0)116 2718642 Leicester, UK ****************************************************************** data=N at Table[{x,y,Sin[x*y]},{x,0,Pi,Pi/10},{y,0,Pi,Pi/10}]; xGrid=Line/@data; yGrid=Line/@(Transpose at data); Show[Graphics3D[{{Hue[0],xGrid},{Hue[.7],yGrid}}],AspectRatio->Automatic, Axes->True,BoxRatios->{1,1,1/Pi}]; You can get more elaborate by adding the surface surface=First@ Graphics3D@ Plot3D[Sin[x*y],{x,0,Pi},{y,0,Pi},PlotPoints->{11,11}, DisplayFunction->Identity]; Show[Graphics3D[{ AbsoluteThickness[1],{Hue[0],xGrid},{Hue[.7],yGrid},{EdgeForm[], surface/.Polygon[pts_]:> Polygon at Module[{centroid=Plus@@pts/Length at pts}, Map[((#-centroid)*.5+centroid)&,pts]]}}], AspectRatio->Automatic,Axes->True,BoxRatios->{1,1,1/Pi}]; Here's a quick explaination on the surface bit. First you use Plot3D to get the data. Because Plot3D uses a matrix to represent the surface, you need to convert it to Polygon, and this is done by adding the head Graphics3D. The command *First* is used to extract the first part of the graphics object, because the second part is a list of options such as Axes->True, which we don't need here. Now we display the xGrid, yGrid, and surface together in Show. For the surface, we shrink each Polygon a bit so it falls inside the grid nicely. This is done by calculating vectors of the centroid to the vertxes of each polygon, scale it to half, and form the vertexes again. Xah, xah at best.com http://www.best.com/~xah/SpecialPlaneCurves_dir/MathematicaPackages_dir/MathematicaPackages .html Mountain View, CA, USA