Graph 从Mathematica 5升级到Mathematica 7

Graph 从Mathematica 5升级到Mathematica 7,graph,wolfram-mathematica,plot,Graph,Wolfram Mathematica,Plot,我正在尝试升级一些目前针对Mathematica 5编写的方程式,以使它们在Mathematica 7中工作 F = Graphics[ ContourPlot[ x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, Contours -> 20, PlotPoints

我正在尝试升级一些目前针对Mathematica 5编写的方程式,以使它们在Mathematica 7中工作

F = Graphics[
  ContourPlot[
   x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
   ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
   Contours -> 20, PlotPoints -> 100]]; 
G = ParametricPlot[{Cos[u], Sin[u]}, {u, 0, 2*Pi}, 
  PlotStyle -> {RGBColor[0, 174/255, 239/255]}]; 
H = DeleteCases[F, {x_, y_} /; (x^2 + y^2 > 1), 5]; 
Show[{H, G}, AspectRatio -> Automatic, Frame -> False, Axes -> True, 
   AxesOrigin -> {0, 0}, AxesLabel -> {x, y}, Ticks -> None]
应该是这样的: ,但id确实是这样的:

它给出了以下错误:

Thread::tdlen: Objects of unequal length in 
  {{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}}+{{},<<21>>,{}} 
  cannot be combined. >>
有很多坐标系的,都有不同的坐标系


我遇到的第二个问题是:

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
    0, 2*Pi}, {v, -Pi/2, Pi/2}}; 
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}}; 
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}}; 
U = {P1, P2, P3, P4}; 
XL = {{-1, 1}, {-1, 1}, {-1, 1}}; 
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; 
XS = {"x", "y", "z"}; 
f[a_, b_, c_] := {a, 1.1*b[[2]]*c}; 
g[a_, b_] := {(b*# &) /@ a}; 
T = Text @@@ MapThread[f, {XS, XL, XV}]; 
A = Line @@@ MapThread[g, {XL, XV}]; 
F = (ParametricPlot3D[Evaluate[Evaluate @@ #]][[1]] &) /@ U; 
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, PlotRange -> XL, 
  ViewPoint -> {2.4, 1.3, 2}, 
  DisplayFunction -> 
   Identity}; 
L = {LightSources -> {{{0.1, 0, 1}, RGBColor[0.68, 0.88, 0.96]}}}; 
gr1 = (Show[Graphics3D[#], OPT, L] &) /@ {{EdgeForm[], F}, {Dashing[{0.03, 0.03}], 
    GrayLevel[0.7], A}, {T}}; 
gr2 = DeleteCases[Graphics[Show[Graphics3D[{A, EdgeForm[], F}], OPT, 
        RenderAll -> False]], {__, _Polygon}, 3]; 
Show[{gr1, gr2}, AspectRatio -> Automatic]
这个应该像:,但确实像:

它给出了以下错误:

ParametricPlot3D::write: Tag Plus in x^2+y^2 is Protected. >>
Graphics3D::optx : Unknown option RenderAll
Graphics3D::optx : Unknown option LightSources
如果删除未知选项,这些错误将消失,但看起来仍然是错误的:

此外,如果您将鼠标悬停在mathematica中的最后一幅图像上,您会在工具提示中看到以下消息重复多次

Times is not a Graphics3D primitive or directive
第一个:

ContourPlot[x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
 ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
 Contours -> 20, RegionFunction -> (#1^2 + #2^2 <= 1 &), 
 BoundaryStyle -> Blue]
  • 我认为轴需要作为独立的内部/外部部分来完成
  • 在这个版本中,大圆圈显示出来;如果需要的话,防止这种情况发生需要绘制部分曲线,而不是网格线
第一个:

ContourPlot[x^2 + (2)*y^2 + (-1)*((1)/(3))*x, {x, -1, 1}, {y, -1, 1}, 
 ContourShading -> False, ContourStyle -> {RGBColor[1, 0, 1]}, 
 Contours -> 20, RegionFunction -> (#1^2 + #2^2 <= 1 &), 
 BoundaryStyle -> Blue]
  • 我认为轴需要作为独立的内部/外部部分来完成
  • 在这个版本中,大圆圈显示出来;如果需要的话,防止这种情况发生需要绘制部分曲线,而不是网格线

从图片中很难看出第二个图形需要什么。请试试这个,告诉我什么是对的,什么是缺的

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
     0, 2*Pi}, {v, -Pi/2, Pi/2}};
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}};
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}};
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}};
U = {P1, P2, P3, P4};
XL = {{-1, 1}, {-1, 1}, {-1, 1}};
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
XS = {"x", "y", "z"};
f[a_, b_, c_] := {a, 1.1*b[[2]]*c};
g[a_, b_] := {(b*# &) /@ a};
T = Text @@@ MapThread[f, {XS, XL, XV}];
A = Line @@@ MapThread[g, {XL, XV}];
F = ParametricPlot3D[##, Mesh -> False][[1]] & @@@ U;
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
   PlotRange -> XL, ViewPoint -> {2.4, 1.3, 2}};
L = Lighting -> {{"Directional", 
     RGBColor[0.68, 0.88, 0.96], {{5, 5, 4}, {5, 5, 0}}}};
gr1 = Graphics3D[#, OPT, L] & /@ {{Opacity[0.5], F},
                                  {Dashing[{0.03, 0.03}], GrayLevel[0.7], A},
                                  {T}};
Show[gr1]
这是另一个可能更接近原作的镜头。您将失去v7使用此选项旋转图形的功能

gr1 = Rasterize[Graphics3D[#, OPT, L], 
     Background -> None] & /@ {F, {Dashing[{0.03, 0.03}], 
     GrayLevel[0.7], A}, T};
Show[gr1]

从图片中很难看出第二个图形需要什么。请试试这个,告诉我什么是对的,什么是缺的

P1 = {{(5)/10*Cos[u]*Cos[v], (5)/10*Sin[u]*Cos[v], (5)/10*Sin[v]}, {u,
     0, 2*Pi}, {v, -Pi/2, Pi/2}};
P2 = {{(5)/10*Cos[u], 0, (5)/10*Sin[u]}, {u, 0, 2*Pi}};
P3 = {{(5)/10*Cos[u], (5)/10*Sin[u], 0}, {u, 0, 2*Pi}};
P4 = {{0, (5)/10*Cos[u], (5)/10*Sin[u]}, {u, 0, 2*Pi}};
U = {P1, P2, P3, P4};
XL = {{-1, 1}, {-1, 1}, {-1, 1}};
XV = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
XS = {"x", "y", "z"};
f[a_, b_, c_] := {a, 1.1*b[[2]]*c};
g[a_, b_] := {(b*# &) /@ a};
T = Text @@@ MapThread[f, {XS, XL, XV}];
A = Line @@@ MapThread[g, {XL, XV}];
F = ParametricPlot3D[##, Mesh -> False][[1]] & @@@ U;
OPT = {Boxed -> False, Axes -> False, BoxRatios -> {1, 1, 1}, 
   PlotRange -> XL, ViewPoint -> {2.4, 1.3, 2}};
L = Lighting -> {{"Directional", 
     RGBColor[0.68, 0.88, 0.96], {{5, 5, 4}, {5, 5, 0}}}};
gr1 = Graphics3D[#, OPT, L] & /@ {{Opacity[0.5], F},
                                  {Dashing[{0.03, 0.03}], GrayLevel[0.7], A},
                                  {T}};
Show[gr1]
这是另一个可能更接近原作的镜头。您将失去v7使用此选项旋转图形的功能

gr1 = Rasterize[Graphics3D[#, OPT, L], 
     Background -> None] & /@ {F, {Dashing[{0.03, 0.03}], 
     GrayLevel[0.7], A}, T};
Show[gr1]

第二个,大圆部分隐藏,轴线部分虚线:

r = 1.01/2; d = 1/(100 r);
v1 = Riffle[
   Table[r { Cos[\[Phi]], Sin[\[Phi]], -d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r {  Cos[\[Phi]], Sin[\[Phi]], d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v2 = Riffle[
   Table[-r {  Cos[\[Phi]], -d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[-r { Cos[\[Phi]], d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v3 = Riffle[
   Table[r { -d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r { d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
lx = {{{1, 0, 0}, {2, 0, 0}}}/2;
ly = {{{0, 1, 0}, {0, 2, 0}}}/2;
lz = {{{0, 0, 1}, {0, 0, 2}}}/2;
A2 = Line @@@ {lx, ly, lz, -lx, -ly, -lz};
Graphics3D[
 {
  FaceForm[None, Black], EdgeForm[],
  GraphicsComplex[#, 
     Table[Polygon[Mod[{i, i + 1, i + 3, i + 2}, Length[v], 1]], {i, 
       1, Length[v] - 1, 2}]] & /@ {v1, v2, v3}, {Opacity[0.75], 
   RGBColor[0.68`, 0.88`, 0.96`], Sphere[{0, 0, 0}, 1/2]},
  {Dashing[{0.02, 0.02}], Black, A}, T, A2
  },
 Boxed -> False, 
 Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
    ImageScaled@{0.1, 0, 1}}}, BoxRatios -> {1, 1, 1}, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
 BaseStyle -> FontSize -> 14, ViewPoint -> {2.4`, 1.3`, 2}, 
 ViewVertical -> {0, 0, 1}
 ]

第二个,大圆部分隐藏,轴线部分虚线:

r = 1.01/2; d = 1/(100 r);
v1 = Riffle[
   Table[r { Cos[\[Phi]], Sin[\[Phi]], -d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r {  Cos[\[Phi]], Sin[\[Phi]], d}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v2 = Riffle[
   Table[-r {  Cos[\[Phi]], -d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[-r { Cos[\[Phi]], d, Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
v3 = Riffle[
   Table[r { -d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}], 
   Table[r { d, Cos[\[Phi]], Sin[\[Phi]]}, {\[Phi], 0, 2 \[Pi], (
     2 \[Pi])/40.}]];
lx = {{{1, 0, 0}, {2, 0, 0}}}/2;
ly = {{{0, 1, 0}, {0, 2, 0}}}/2;
lz = {{{0, 0, 1}, {0, 0, 2}}}/2;
A2 = Line @@@ {lx, ly, lz, -lx, -ly, -lz};
Graphics3D[
 {
  FaceForm[None, Black], EdgeForm[],
  GraphicsComplex[#, 
     Table[Polygon[Mod[{i, i + 1, i + 3, i + 2}, Length[v], 1]], {i, 
       1, Length[v] - 1, 2}]] & /@ {v1, v2, v3}, {Opacity[0.75], 
   RGBColor[0.68`, 0.88`, 0.96`], Sphere[{0, 0, 0}, 1/2]},
  {Dashing[{0.02, 0.02}], Black, A}, T, A2
  },
 Boxed -> False, 
 Lighting -> {{"Directional", RGBColor[0.68`, 0.88`, 0.96`], 
    ImageScaled@{0.1, 0, 1}}}, BoxRatios -> {1, 1, 1}, 
 PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}, 
 BaseStyle -> FontSize -> 14, ViewPoint -> {2.4`, 1.3`, 2}, 
 ViewVertical -> {0, 0, 1}
 ]

太好了,谢谢,我尝试过排除,但没有成功。如果我得不到更多的答案,我明天会接受你的答案。那太好了,谢谢,我试过排除,但没用。如果我得不到更多的答案,我明天会接受你的答案。这看起来很接近,不幸的是我不知道这是想显示什么,因为我刚刚得到了一大堆方程,并被告知让它们看起来与版本5的输出相同,我的意思是,它看起来像一个球体,我不知道这个例子的目的是什么。看起来很接近,不幸的是,我不知道这是想显示什么,因为我刚刚得到了一大堆方程,并被告知使它们看起来与第5版的输出相同,我的意思是,它看起来就像一个球体,我不知道这个例子的目的是什么。事实上,这仍然是不完整的。实心轴应该被球体隐藏,但不是。幸运的是,由于视角的原因,你看不到这一点。事实上,这还没有完成。实心轴应该被球体隐藏,但不是。由于视角的原因,你很幸运地看不到这一点。