2
$\begingroup$

In the documentation for GraphicsGrid, it says

By default, GraphicsGrid will display graphics at their specified sizes

So why does it rescale the 3d plots even if I have set the ImageSize option?

For example:

GraphicsGrid@Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, ImageSize -> 200], {2}, {2}]

gives the scaled 3d plots, regarding I have set the image size

enter image description here

while it doesn't rescale the 2d plots

enter image description here

So why does GraphicsGrid rescale 3d plots?

$\endgroup$
3
  • 1
    $\begingroup$ I believe that by "graphics", the documentation is tacitly referring to Graphics, and not Graphics3D $\endgroup$
    – ciao
    May 25, 2014 at 6:53
  • $\begingroup$ If so, could be a bit clearer?! $\endgroup$ May 25, 2014 at 10:08
  • $\begingroup$ @rasher That's confusing, because in the documentation of Grid, it says "Grid will not change the size of graphics or other objects that have explicit ImageSize settings. " and it does not rescale 3d plots. $\endgroup$ May 25, 2014 at 15:10

2 Answers 2

5
$\begingroup$

I tried using {200,200} to specify width and height instead of just width (200), and for some reason I was able to specify the size of the 3D plots i.e. stop the rescaling. I suspect that 3D plots need to be specified in more dimensions than their 2D counterparts in order to be displayed properly at the size you want.

Here's a summary of the codes and outputs I tested. Strangely when I included 2 squares at the end to check the size of mine and eldo's solutions, neither of ours match the size of the squares. I'm not sure if that's the fault of our solutions or of the squares being improperly set up. I'm a newbie at Mathematica--waiting for my copy of Mathematica Navigator to arrive(!)--so I may very well not know what the heck I'm doing.

PS: I'm also a college student in LA! Not at LSU though.

{
  (*OP's situation: changing ImageSize does not change size of plots in grid*)
  {GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 200], {2}, {2}], Frame -> All], 
   GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 100], {2}, {2}], Frame -> All]},

  (*My--seismatica's--suggestion: use {w,h} to specify width & height instead of just width*)
  {GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> {200, 200}], {2}, {2}], Frame -> All],
   GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> {100, 100}], {2}, {2}], Frame -> All]},

  (*eldo's suggestion: use Grid*)
  {Grid[Table[
     Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 200], {2}, {2}], Frame -> All],
   Grid[Table[
     Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 100], {2}, {2}], Frame -> All]},

  (*Squares of specified dimensions, for reference*)
  {Graphics[Rectangle[], ImageSize -> 200],
   Graphics[Rectangle[], ImageSize -> 100]}
  } // TableForm

Output comparisons

Edit: I suspected the mismatch in size (between the plots and the reference square) is due to padding of (Graphics)Grid. However, after removing the padding--by setting Spacings to {0,0}, the mismatch is still there. Also, for some reason, eldo's grid loses the internal horizontal frame after removing spacing. Not quite sure what's going on :/

{
  (*OP's situation: changing ImageSize does not change size of plots in grid*)
  {GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 200], {2}, {2}], Frame -> All, Spacings -> {0, 0}],
    GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 100], {2}, {2}], Frame -> All, Spacings -> {0, 0}]},

  (*My--seismatica's--suggestion: use {w,h} to specify width & height instead of just width*)
  {GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> {200, 200}], {2}, {2}], Frame -> All, 
    Spacings -> {0, 0}],
   GraphicsGrid[
    Table[Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> {100, 100}], {2}, {2}], Frame -> All, 
    Spacings -> {0, 0}]},

  (*Squares of specified dimensions, for reference*)
  {Graphics[Rectangle[], ImageSize -> 200],
   Graphics[Rectangle[], ImageSize -> 100]},

  (*eldo's suggestion: use Grid*)
  {Grid[Table[
     Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 200], {2}, {2}], Frame -> All, Spacings -> {0, 0}],
   Grid[Table[
     Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
      ImageSize -> 100], {2}, {2}], Frame -> All, Spacings -> {0, 0}]},
  } // TableForm

Output comparisons without padding

$\endgroup$
3
  • $\begingroup$ Please include any relevant code, not just images. $\endgroup$
    – Sektor
    May 25, 2014 at 12:04
  • $\begingroup$ Thanks :) Which college are you at? $\endgroup$ May 25, 2014 at 23:10
  • $\begingroup$ I'm at UL ;) ugh10char $\endgroup$
    – seismatica
    May 26, 2014 at 1:17
2
$\begingroup$

I would use:

Grid@Table[
  Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, 
   ImageSize -> 300], {2}, {2}]
$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.