8
$\begingroup$

Aligning my images in Grid causes one of them to become smaller, despite specifying each of their sizes with ImageSize:

dat = Table[{x, y, RandomReal[]*x*y}, {x, 1, 50}, {y, 1, 50}];
img = ListContourPlot[Flatten[dat, 1], ImageSize -> {300, 300}];
oldspotlight = 
  Graphics[{}, Background -> Black, PlotRange -> {{1, 50}, {1, 50}}, 
   ImageSize -> 300];
a=Show[img, 
 Graphics[{Circle[{90, 60}, 10]}, PlotRange -> {{1, 50}, {1, 50}}, 
  ImageSize -> {300, 300}]]
b=ImageMultiply[img, 
 ImageAdd[oldspotlight, 
  Graphics[{ColorData["GrayTones"][10/20], Disk[{90, 60}, 10]}, 
   Background -> Black, PlotRange -> {{1, 50}, {1, 50}}, 
   ImageSize -> {300, 300}]]]
Grid[{{a,b}}]

Output:

enter image description here

enter image description here

enter image description here

Please note that I don't want to use GraphicsGrid. (The reason is because it doesn't cooperate with Dynamic, which is an unrelated question.)

$\endgroup$
9
  • $\begingroup$ If you could find a simple that example that still has this problem, it would be easier to help. Right now there is a lot of code, but most of it is unrelated to your problem. $\endgroup$
    – C. E.
    Commented Dec 14, 2013 at 17:11
  • $\begingroup$ Anon: I made the code a little simpler $\endgroup$
    – user8454
    Commented Dec 14, 2013 at 17:16
  • $\begingroup$ Curious. From the documentation: Grid will not change the size of graphics or other objects that have explicit ImageSize settings. $\endgroup$
    – DavidC
    Commented Dec 14, 2013 at 17:28
  • $\begingroup$ Does Row[{img, oldspotlight}] do what you want? It does not resize. $\endgroup$
    – bill s
    Commented Dec 14, 2013 at 17:44
  • $\begingroup$ Sorry @bill s, for the non-minimum working example, but I would want Row[{a,b}], which worsens the problem $\endgroup$
    – user8454
    Commented Dec 14, 2013 at 17:46

3 Answers 3

3
$\begingroup$

One way to do it, which would be a minimal change to your current code, is just wrap image b in Show as you did with image a and give the ImageSize option to this second Show.

dat = Table[{x, y, RandomReal[]*x*y}, {x, 1, 50}, {y, 1, 50}];
img = ListContourPlot[Flatten[dat, 1], ImageSize -> {300, 300}];
oldspotlight = 
  Graphics[{}, Background -> Black, PlotRange -> {{1, 50}, {1, 50}}, 
   ImageSize -> 300];
a = Show[img, 
  Graphics[{Circle[{90, 60}, 10]}, PlotRange -> {{1, 50}, {1, 50}}, 
   ImageSize -> {300, 300}]];
b = Show[ImageMultiply[img, 
   ImageAdd[oldspotlight, 
    Graphics[{ColorData["GrayTones"][10/20], Disk[{90, 60}, 10]}, 
     Background -> White, PlotRange -> {{1, 50}, {1, 50}}]]], 
  ImageSize -> {300, 300}];
Grid[{{a, b}}]

enter image description here

$\endgroup$
9
$\begingroup$

ImageSizeMultiplers

  • ImageSizeMultipliers is an option that specifies how much smaller to render graphics that appear within other constructs.

  • ImageSizeMultipliers -> {u,v} specifies that graphics inside list-like constructs should be u times their normal size, while graphics inside function-like constructs should be v times their normal size.

  • A typical default setting for ImageSizeMultipliers is {0.5, 0.25}.

So we can use

Style[Grid[{{a, b}}], ImageSizeMultipliers -> {1, 1}]

enter image description here

$\endgroup$
2
$\begingroup$

How about using Row:

Row[{img, "  ", oldspotlight}]

or

Row[{a, "  ", Image[b, ImageSize -> 300]}]

both of which give:

enter image description here

(I added the " " to make some space between them).

$\endgroup$
1
  • $\begingroup$ I wish I could also accept this as the answer! $\endgroup$
    – user8454
    Commented Dec 14, 2013 at 18:08

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.