500
500

Reputation: 6619

Fit to Notebook Width ImageSize in Mathematica

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

Upvotes: 7

Views: 775

Answers (3)

Verbeia
Verbeia

Reputation: 4420

For two graphics objects side by side use the ImageSize option to 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}]

enter image description here

Upvotes: 5

abcd
abcd

Reputation: 42235

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.

Upvotes: 5

acl
acl

Reputation: 6520

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}
 ]

Upvotes: 9

Related Questions