3
$\begingroup$

I would like to arrange the density plots in a certain order using GraphicsGrid. But when using GraphicsGrid, there is problem with the color scale, it doesn't display completely. How should GraphicsGrid be written so that the color scales of the density plots are displayed correctly?

ClearAll["Global`*"]

f[B_] := B*(r^2 + z^2)*Sin[z]^2;

ff = Table[
  DensityPlot[f[B], {r, 0, 10}, {z, -5, 5}, FrameLabel -> {r, z}, 
   PlotLabel -> StringForm["B = ``", B], 
   ColorFunction -> "SunsetColors", PlotPoints -> 250, 
   PlotLegends -> Automatic, ImageSize -> 200], {B, {0, 5, 10, 25}}]

GraphicsGrid[{{ff[[1]], ff[[3]]}, {ff[[2]], ff[[4]]}}]
$\endgroup$
2
  • 1
    $\begingroup$ Add ImageSize -> 550 to the GraphicsGrid or use Grid instead of GraphicsGrid $\endgroup$
    – Bob Hanlon
    Commented Sep 10, 2023 at 13:47
  • $\begingroup$ @Bob Hanlon, thanks! It works $\endgroup$
    – Mam Mam
    Commented Sep 11, 2023 at 10:33

1 Answer 1

2
$\begingroup$

Graphics and Inset give you more control, e.g.

{{f1, f3}, {f2, f4}} = {{ff[[1]], ff[[3]]}, {ff[[2]], ff[[4]]}};
{x, y} = {280, 220};
Graphics[{White, Rectangle[{0, 0}, {2 x, 2 y}],
  Inset[f1, {x/2, 2 y - y/2}, Center, x],
  Inset[f2, {2 x - x/2, 2 y - y/2}, Center, x],
  Inset[f3, {x/2, y/2}, Center, x],
  Inset[f4, {2 x - x/2, y/2}, Center, x]}, 
 PlotRange -> {{0, 2 x}, {0, 2 y}}, ImageSize -> 2 x]
$\endgroup$

Your Answer

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

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