如何使用Manipulate Plot消除不需要的空白区域

时间:2014-05-14 12:33:26

标签: wolfram-mathematica mathematica-7

我试图制作下一个简单的交互式情节:

Needs["PlotLegends`"]
rTE[\[Theta]_, n1_, n2_] := 
 Abs[(n1*Cos[\[Theta]] - 
     n2*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])/(n1*Cos[\[Theta]] + 
     n2*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])]
rTM[\[Theta]_, n1_, n2_] := 
 Abs[(n2*Cos[\[Theta]] - 
     n1*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])/(n2*Cos[\[Theta]] + 
     n1*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])]
tTE[\[Theta]_, n1_, n2_] := 
 Abs[(2*n1*Cos[\[Theta]])/(n1*Cos[\[Theta]] + 
     n2*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])]
tTM[\[Theta]_, n1_, n2_] := 
 Abs[(2*n1*Cos[\[Theta]])/(n2*Cos[\[Theta]] + 
     n1*Cos[ArcSin[n1*Sin[\[Theta]]/n2]])]
RTE[\[Theta]_, n1_, n2_] := Abs[(rTE[\[Theta], n1, n2])^2]
RTM[\[Theta]_, n1_, n2_] := Abs[(rTM[\[Theta], n1, n2])^2]
TTE[\[Theta]_, n1_, n2_] := 
 Abs[(tTE[\[Theta], n1, n2])^2*(n2*
      Cos[ArcSin[n1*Sin[\[Theta]]/n2]])/(n1*Cos[\[Theta]])]
TTM[\[Theta]_, n1_, n2_] := 
 Abs[(tTM[\[Theta], n1, n2])^2*(n2*
      Cos[ArcSin[n1*Sin[\[Theta]]/n2]])/(n1*Cos[\[Theta]])]
Manipulate[
 GraphicsRow[{Plot[{rTM[\[Theta], n1, n2], rTE[\[Theta], n1, n2], 
     tTM[\[Theta], n1, n2], tTE[\[Theta], n1, n2]}, {\[Theta], 
     0, \[Pi]/2}, PlotStyle -> Thick, 
    PlotLegend -> {"rTM[\[Theta]]" , "rTE[\[Theta]]", 
      "tTM[\[Theta]]" , "tTE[\[Theta]]"}, LegendPosition -> {1, -0.4},
     PlotMarkers -> Automatic, AxesLabel -> Automatic, 
    PlotRange -> {0, 1}], 
   Plot[{RTM[\[Theta], n1, n2], RTE[\[Theta], n1, n2], 
     TTM[\[Theta], n1, n2], TTE[\[Theta], n1, n2]}, {\[Theta], 
     0, \[Pi]/2}, PlotStyle -> Thick, 
    PlotLegend -> {"RTM[\[Theta]]" , "RTE[\[Theta]]", 
      "TTM[\[Theta]]" , "TTE[\[Theta]]"}, LegendPosition -> {1, -0.4},
     PlotMarkers -> Automatic, AxesLabel -> Automatic, 
    PlotRange -> {0, 1}]}, ImageSize -> 800, Frame -> All, 
  Spacings -> {0, -300}], {n1, 1, 3.6}, {n2, 1, 3.6}, 
 ImageMargins -> Tiny, ControlType -> InputField, Alignment -> Top]

我没有足够的声誉来发布结果图片,但你可以在这里看到它:

https://dl.dropboxusercontent.com/u/21949826/picture.png

如您所见 - 地块上方和下方的空白区域太多。我怎么能摆脱这个?

谢谢!

1 个答案:

答案 0 :(得分:0)

使用GridGraphicsGrid(或GraphicsRow)更容易。你的意思是:

Manipulate[
 Grid[{{Plot[{rTM[\[Theta], n1, n2], rTE[\[Theta], n1, n2], 
      tTM[\[Theta], n1, n2], tTE[\[Theta], n1, n2]}, {\[Theta], 
      0, \[Pi]/2}, PlotStyle -> Thick, 
     PlotLegend -> {"rTM[\[Theta]]", "rTE[\[Theta]]", "tTM[\[Theta]]",
        "tTE[\[Theta]]"}, LegendPosition -> {1, -0.4}, 
     AxesLabel -> Automatic, PlotRange -> {0, 1}, ImageSize -> 400],
    Plot[{RTM[\[Theta], n1, n2], RTE[\[Theta], n1, n2], 
      TTM[\[Theta], n1, n2], TTE[\[Theta], n1, n2]}, {\[Theta], 
      0, \[Pi]/2}, PlotStyle -> Thick, 
     PlotLegend -> {"RTM[\[Theta]]", "RTE[\[Theta]]", "TTM[\[Theta]]",
        "TTE[\[Theta]]"}, LegendPosition -> {1, -0.4}, 
     AxesLabel -> Automatic, PlotRange -> {0, 1}, 
     ImageSize -> 400]}}], {n1, 1, 3.6}, {n2, 1, 3.6}, 
 ControlType -> InputField, Alignment -> Top]