适合Mathematica中的笔记本宽度ImageSize

500*_*500 6 graphics wolfram-mathematica

是否存在ImageSize的参数,使得Graphics或Manipulate自动适合Notebook Width.

acl*_*acl 9

怎么样

Plot[Sin[x], {x, -5, 5}, ImageSize -> Full]
Run Code Online (Sandbox Code Playgroud)

编辑:或

Manipulate[
 Show[
  {
   Plot[Sin[alpha*x], {x, -5, 5}],
   Plot[Cos[alpha*x], {x, -5, 5}]
   },
  ImageSize -> Full
  ],
 {alpha, 1, 2}
 ]
Run Code Online (Sandbox Code Playgroud)


abc*_*bcd 5

除了 Acl 的解决方案之外,还有另一个选择:

width := 0.85Cases[NotebookGet[], (WindowSize -> {x_, _}) -> x]
Plot[Sin[x], {x, -5, 5}, ImageSize -> {width, Automatic}]
Run Code Online (Sandbox Code Playgroud)

这种方法的缺点是左侧的空间(你有In[10]:=等)是恒定的,并且不会随着笔记本宽度的变化而变化。因此,我上面使用的宽度百分比将根据您笔记本的宽度而变化。有可能弥补这一点,但我不会这样做。然而,一旦你确定了宽度并找到了最佳位置,它应该会很好。

当您需要显式提供尺寸/坐标并且无法使用诸如 之类的选项时,这非常有用Full


Ver*_*eia 5

对于两个图形对象并排使用ImageSize选项GraphicsRow

Manipulate[
 GraphicsRow[{Show[{Plot[Sin[alpha*x], {x, -5, 5}], 
     Plot[Cos[alpha*x], {x, -5, 5}]}], 
   Show[{Plot[Sin[alpha*x], {x, -5, 5}], 
     Plot[Cos[beta*x], {x, -5, 5}]}]}, ImageSize -> Full], {alpha, 1, 
  2}, {beta, 1, 2}]
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述