FlatEllipsoid[x_, y_, dz_] := dz^2 + x^2/25 + y^2/9

RandomOffsets = 
  Table[RandomReal[UniformDistribution[{-1, 1}]], {i, 100}];

g=Table[ContourPlot[
  FlatEllipsoid[x, y, RandomOffsets[[i*j]]] == 1, {x, -5, 
   5}, {y, -3.5, 3.5}, PlotRange -> {{-5.5, 5.5}, {-3.5, 3.5}}, 
  AspectRatio -> 0.6], {i, 1, 10}, {j, 1, 10}]

enter image description here

When I wrap g to GraphicsGrid it gives a messy output. What is the proper way to combine the graphic objects of g?

  • GraphicsGrid is not bad per se, you can e.g. simply use a dedicated ImageSize either in your for your plots or the GraphicsGrid. – Yves Klett Dec 2 '15 at 13:45
up vote 1 down vote accepted

You can get what you want out of GraphicsGrid, by writing GraphicsGrid[g,ImageSize -> n] where n is the total width of the grid, but I still find that it hogs more system resources than Grid. But Grid will simply display the plots at their own predefined size, you can't adjust the overall size of the Grid.

That's why I stay away from GraphicsGrid, GraphicsRow and GraphicsColumn whenever possible, I just use Grid

Grid[g]

enter image description here

But better than that, use Jens's plotGrid function to get rid of all that white space and duplication of tick marks.

 plotGrid[g, 1200, 720]

enter image description here

  • Thanks. I found this in an old book. It uses GraphicsArray. I thought GraphicsArray has been replaced by GraphicsGrid. – dimitris Dec 2 '15 at 13:38
  • Apparently it is still there, but the help page says "As of Version 6.0, GraphicsArray has been superseded by GraphicsGrid and Grid." – Jason B. Dec 2 '15 at 13:45
  • Both answers are great. Thanks a lot! – dimitris Dec 2 '15 at 17:06

I would use FrameTicks -> None

g =
  Table[
   ContourPlot[
    FlatEllipsoid[x, y, RandomOffsets[[i*j]]] == 1, {x, -5, 5}, {y, -3.5, 3.5},
    FrameTicks -> None,
    PlotRange -> {{-5.5, 5.5}, {-3.5, 3.5}},
    AspectRatio -> 0.6],
   {i, 1, 2}, {j, 1, 5}];

And then

Grid[g, Spacings -> {-1, -1}]

enter image description here

Or

Grid[g, Spacings -> {-1, -1}, Dividers -> All]

enter image description here

Or label them somwhow with Epilog and Text

g =
 Table[
  ContourPlot[
   FlatEllipsoid[x, y, RandomOffsets[[i*j]]] == 1, {x, -5, 5}, {y, -3.5, 3.5},
   FrameTicks -> None,
   Epilog -> Text[Row[{i, " ", j}]],
   PlotRange -> {{-5.5, 5.5}, {-3.5, 3.5}},
   AspectRatio -> 0.6],
  {i, 1, 2}, {j, 1, 5}];

Grid[g, Spacings -> {-1, -1}]

enter image description here

You can use ArrayReshape to modify the layout:

Grid[ArrayReshape[g, {5, 2}], Spacings -> {-1, -1}]

enter image description here

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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