4
$\begingroup$

I have relatively simple question. I need to control size and background color of the following two zones separately (indicated by blue and magenta arrows on the figure).

enter image description here

Using Framed options I can control margins and background color of the whole zone.

Question Can I choose a color of the zone shown with blue arrow separately? (It can be changed by PlotRangePadding). Put it differently, how to address the "border" of the graphics object highlighted with the gray arrow?

Code snippet to play around is below:

Manipulate[
 Framed[GraphicsGrid[{
    {
     Graphics3D[Background -> Green, ImagePadding -> 20], 
     Graphics3D[Background -> Yellow, ImagePadding -> 0]
     }
    }, Background -> LightGray, ImageSize -> {400, 200}, 
   Frame -> True, PlotRangePadding -> {a, b}],
  FrameStyle -> Red, FrameMargins -> 30, Background -> White
  ]

 , {{a, 20}, 0, 20, 1, Appearance -> "Labeled"}
 , {{b, 20}, 0, 20, 1, Appearance -> "Labeled"}
 ]

Why? I need this functionality to use with screen-recording software.

There is also a related question 91739.

$\endgroup$
7
$\begingroup$

I think adding another frame will do what you want. Like so:

Manipulate[
  Framed[
    Framed[
      GraphicsGrid[
        {{Graphics3D[Background -> Green, ImagePadding -> 20], 
          Graphics3D[Background -> Yellow, ImagePadding -> 0]}},
         Background -> LightGray,
         ImageSize -> {400, 200},
         Frame -> True],
      FrameStyle -> None,
      Background -> Red,
      FrameMargins -> {{a, a}, {b, b}}],
    FrameStyle -> {Red, AbsoluteThickness[2]},
    FrameMargins -> 30,
    Background -> White],
  {{a, 20}, 0, 20, 1, Appearance -> "Labeled"},
  {{b, 20}, 0, 20, 1, Appearance -> "Labeled"}]

framing

| improve this answer | |
$\endgroup$
6
$\begingroup$

You can use Show to modify the background of the Graphics expression returned by GraphicsGrid:

Manipulate[
 Framed[
  Show[
   GraphicsGrid[
    {{Graphics3D[Background -> Green, ImagePadding -> 20], 
      Graphics3D[Background -> Yellow, ImagePadding -> 0]}},
    Background -> LightGray,
    ImageSize -> {400, 200}, Frame -> True, 
    PlotRangePadding -> {a, b}
    ],
   Background -> Red
   ],
  FrameStyle -> Red, FrameMargins -> 30, Background -> White
  ],
 {{a, 20}, 0, 20, 1, Appearance -> "Labeled"},
 {{b, 20}, 0, 20, 1, Appearance -> "Labeled"}
 ]

enter image description here

This works because GraphicsGrid returns a Graphics expression with the contents placed as Inset. The Background specified in the options to GraphicsGrid is implemented using Rectangle directives, since it needs to be flexible enough to support coloring of individual grid cells, which also explains why the PlotRangePadding is added "around" the background.

| improve this answer | |
$\endgroup$
  • $\begingroup$ thank you, your answer is nice, I wish I could choose both. $\endgroup$ – garej Jan 7 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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