Skip to main content
Tweeted twitter.com/StackMma/status/906235844746457088
edited title
Link

GraphiscGrid GraphicsGrid of plots with legends

edited tags
Link
Source Link

GraphiscGrid of plots with legends

I use GraphicsGrid to get a table of contour plots, where each of the plots is using its own scaling, so I want to include the bar legend for each of the plots. But if I do this, GraphicsGrid seems to ignore the place needed for the legend when calculating the grid item size, and the plots are scaled larger then grid cells.

MWE:

GraphicsGrid@ Table[ContourPlot[ Cos[x]/k + Cos[ m y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, ColorFunction -> "Rainbow", PlotLegends -> Automatic], {k, 1, 2}, {m, 1, 2}] 

oversized items in GrpahicsGrid

Is there any better way to fix it rather then to set fixed plot size and to tune manually the ItemAspectRatio, like below?

GraphicsGrid[ Table[ContourPlot[ Cos[x]/k + Cos[ m y], {x, 0, 4 Pi}, {y, 0, 4 Pi}, ColorFunction -> "Rainbow", PlotLegends -> Automatic, ImageSize -> 100], {k, 1, 2}, {m, 1, 2}], ItemAspectRatio -> .6] 

enter image description here