|
|
三维图形的Log坐标显示
(这条文章已经被阅读了 2992 次) 时间:2009/04/22/09:40
来源:even2004
Log坐标下显示三维图形包括两层意思:三维图形和对应的Log坐标。 一般的说,三维图形可以用ParametricPlot3D来画。把f(x,y,z)的函数表示成x=f(u,v), y=g(u,v), z=h(u,v). 例如:z = x + y, 这个函数可以写成: x = u; y=v; z= u + v. 又例如: x^3=4y可以写成:x=u; y=u^3/4; z=v. 又例如: z = Sin[x]可以写成: x=u; y=v; z=Sin(u). 为了在Log坐标下显示, ParametricPlot3D[{fx,fy,fz},...]画图的时候,三个参数应该是:{fx,fy, fz}=Log@{x,y,z}. 第二步就是把坐标改成Log坐标。 这个其实就是把一些10^n的数,(例如0.01,0.1, 10, 100, 10^10...)对应到Log坐标下的本身的数值: Log[0.01], Log[0.1], Log[10], Log[100], .... 当然其它的对图像修饰的参数保留下来。所以我们只需要把画好的3维图像传递到Log坐标下就可以了。函数如下: LogTicksPlot3D [f_List?(And @@ Map[MatchQ[#, _Graphics3D] &, #] &), Opts__Rule : (AspectRatio -> 1/GoldenRatio)] := Module[{ff, tick, ticknew, optns}, tick = FilterRules[{Opts}, Ticks]; optns = Complement[FilterRules[{Opts}, Options[Graphics3D]], tick]; ff[a_, b_] := With[{sggst = {Floor[Log[10, a]], Ceiling[Log[10, b]], 1}}, set1 = N[{Log[10^#], If[(# > 3) || (# < -2), Superscript["10", ToString[#]], 10^#]}] & /@ (Range @@ sggst); set2 = Flatten[(Function[{aaa, bbb}, {#, "", {0.00375, 0.}, {Thickness[0.001`]}} & /@ (N[ Log /@ ((Range[10^aaa, 10^bbb, 10^aaa])[[2 ;; -2]])])] @@@ (Partition[ Range @@ sggst, 2, 1])), 1]; Union[set1, set2]]; If[Length[tick] == 0, Graphics3D[f[[All, 1]], Evaluate@FilterRules[{Opts}, Options[Graphics3D]]], tick = tick[[1, 2]]; ticknew = tick /. {a_, b_} :> ff[a, b]; Graphics3D[f[[All, 1]], optns, Ticks -> ticknew] ]] 例子:先画3个图: p = ParametricPlot3D[ Log@{x, y, (x + y + 0.072)/3}, {x, 0.01, 10}, {y, 0.01, 10}, PlotRange -> All, AxesLabel -> {x, y, z}, PlotStyle -> Red]; q = ParametricPlot3D[ Log@{x, y, (2.24 - x - y)}, {x, 0.01, 10}, {y, 0.01, 10}, PlotRange -> All, AxesLabel -> {x, y, z}, MaxRecursion -> 5, PlotPoints -> 100]; r = ParametricPlot3D[ Log@{x, x^0.82/65.96, z}, {x, 0.01, 10}, {z, 0.001, 100}, PlotRange -> All, AxesLabel -> {x, y, z}]; 修改坐标: LogTicksPlot3D[{p, q, r}, Axes -> True, Ticks -> {{0.01, 10}, {0.01, 10}, {0.001, 100}}, AxesLabel -> {x, y, z}, AspectRatio -> 1, ViewPoint -> {-1, -2, 3}]
|
|