Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fit to Notebook Width ImageSize in Mathematica

Is there an argument for ImageSize such that the Graphics or Manipulate automatically fits the Notebook Width.

like image 273
500 Avatar asked Nov 17 '11 23:11

500


2 Answers

How about

Plot[Sin[x], {x, -5, 5}, ImageSize -> Full]

EDIT: or

Manipulate[
 Show[
  {
   Plot[Sin[alpha*x], {x, -5, 5}],
   Plot[Cos[alpha*x], {x, -5, 5}]
   },
  ImageSize -> Full
  ],
 {alpha, 1, 2}
 ]
like image 191
acl Avatar answered Nov 04 '22 00:11

acl


Here is another option apart from Acl's solution:

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

The drawback with this approach is that the space on the left (where you have In[10]:=, etc.) is constant and doesn't change with notebook width. So the % of the width I have used above will vary depending on the width of your notebook. It is possible to compensate for that, but I'm not going to do that. However, once you fix your width and find a sweet spot, it should be good.

This is useful in cases where you need to explicitly provide the dimensions/coordinates and can't use an option like Full.

like image 26
abcd Avatar answered Nov 04 '22 00:11

abcd