Test1[body___, xmin_, xmax_, ymin_, ymax_, step_, AxesLab_,
opts : OptionsPattern[]] :=
Plot3D[
Abs[toPlot[body]], {x, xmin, xmax}, {y, ymin, ymax},
ColorFunction ->
Function[{x, y, z},
Hue[(Arg[toPlot[body]] + \[Pi])/(2 \[Pi]) , 1, 1, 1]],
AxesLabel -> AxesLab,
WorkingPrecision -> step,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality",
Evaluate[FilterRules[{opts}, Options[Plot3D]]]];
Test1[xmin_, xmax_, ymin_, ymax_, step_: MachinePrecision] :=
Test1[x + I y, xmin, xmax, ymin, ymax, step, {Re[x], Im[x], Abs[y]}];
toPlot[x_] := Tan[x];
Test1[-5, 5, -5, 5, MachinePrecision]
Test2[xmin_, xmax_, ymin_, ymax_, step_, AxesLab_,
opts : OptionsPattern[]] :=
Plot3D[
Abs[toPlot[x + I y]], {x, xmin, xmax}, {y, ymin, ymax},
ColorFunction ->
Function[{x, y, z},
Hue[(Arg[toPlot[x + I y]] + \[Pi])/(2 \[Pi]) , 1, 1, 1]],
AxesLabel -> AxesLab,
WorkingPrecision -> step,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality",
Evaluate[FilterRules[{opts}, Options[Plot3D]]]];
Test2[-5, 5, -5, 5, MachinePrecision, {Re[x], Im[x], Abs[y]}]
Mathematica 8.0,同一个ColorFunction(应该是同一个,我应该没写错代码),居然出了三种结果,何解?
============================================================
改用新方法:
In[98]:= Function[{x, y, z}, #] &@(Hue[(Arg[toPlot[x + I y]] /2)*Pi +
0.5, 1, 1, 1])
Test4[plotBody___, colorBody___, xmin_, xmax_, ymin_, ymax_, step_,
AxesLab_, opts : OptionsPattern[]] :=
Plot3D[
plotBody, {x, xmin, xmax}, {y, ymin, ymax},
ColorFunction -> Function[{x, y, z}, #] &@(colorBody),
AxesLabel -> AxesLab,
WorkingPrecision -> step,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality",
Evaluate[FilterRules[{opts}, Options[Plot3D]]]];
toPlot[x_] := Tan[x];
Test4[ Abs[toPlot[x + I*y]],
Hue[(Arg[toPlot[x + I y]] /2)*Pi + 0.5, 1, 1,
1], -5, 5, -5, 5, MachinePrecision, {Re[x], Im[x], Abs[y]}]
Out[98]= Function[{x, y, z},
Hue[0.5 + 1/2 \[Pi] Arg[Tan[x + I y]], 1, 1, 1]]
\:6B63\:5728\:8BA1\:7B97In[98]:= Plot3D::pllim: Range specification (ColorFunction->Function[{x,y,z},#1]&)[Abs[Tan[x+I y]],Hue[0.5 +1/2 \[Pi] Arg[Tan[x+Times[<<2>>]]],1,1,1]] is not of the form {x, xmin, xmax}.
Out[101]= Plot3D[{x, -5, 5}, {y, -5,
5}, (ColorFunction -> Function[{x, y, z}, #1] &)[Abs[Tan[x + I y]],
Hue[0.5 + 1/2 \[Pi] Arg[Tan[x + I y]], 1, 1, 1]],
AxesLabel -> {Re[x], Im[x], Abs[y]},
WorkingPrecision -> MachinePrecision,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality", {}]
In[102]:=
Test5[colorBody___, xmin_, xmax_, ymin_, ymax_, step_, AxesLab_,
opts : OptionsPattern[]] :=
Plot3D[
Abs[toPlot[x + I*y]], {x, xmin, xmax}, {y, ymin, ymax},
ColorFunction -> Function[{x, y, z}, #] &@(colorBody),
AxesLabel -> AxesLab,
WorkingPrecision -> step,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality",
Evaluate[FilterRules[{opts}, Options[Plot3D]]]];
Test5[ Hue[(Arg[toPlot[x + I y]] /2)*Pi + 0.5, 1, 1,
1], -5, 5, -5, 5, MachinePrecision, {Re[x], Im[x], Abs[y]}]
\:6B63\:5728\:8BA1\:7B97In[102]:= Plot3D::nonopt: Options expected (instead of (ColorFunction->Function[{x,y,z},#1]&)[Hue[0.5 +1/2 \[Pi] Arg[Tan[x+Times[<<2>>]]],1,1,1]]) beyond position 3 in Plot3D[Abs[toPlot[x+I y]],{x,-5,5},{y,-5,5},(ColorFunction->Function[{x,y,z},#1]&)[Hue[0.5 +1/2 \[Pi] Arg[Tan[Plus[<<2>>]]],1,1,1]],AxesLabel->{Re[x],Im[x],Abs[y]},WorkingPrecision->MachinePrecision,ExclusionsStyle->{Opacity[0.5],Directive[Thick,Blue]},BoundaryStyle->Directive[Red,Thick],PerformanceGoal->Quality,{}]. An option must be a rule or a list of rules.
Out[103]= Plot3D[
Abs[toPlot[x + I y]], {x, -5, 5}, {y, -5,
5}, (ColorFunction -> Function[{x, y, z}, #1] &)[
Hue[0.5 + 1/2 \[Pi] Arg[Tan[x + I y]], 1, 1, 1]],
AxesLabel -> {Re[x], Im[x], Abs[y]},
WorkingPrecision -> MachinePrecision,
ExclusionsStyle -> {Opacity[0.5], Directive[Thick, Blue]},
BoundaryStyle -> Directive[Red, Thick],
PerformanceGoal -> "Quality", {}]
依然不能得到预期结果。