2
$\begingroup$

When using ImageAssemble to combine several images, the size difference between them is a big problem. This problem contains the following parts

  1. ImageSize option may not generate the exact size you want. As shown in the code, two images have the same setting with ImageSize->22*22 but the actual dimensions of them are different. fig1 is {484,329} while fig2 is {484,323}.How to keep them in an exactly same size ?

    ClearAll[fig1, fig2];
    fig1 = Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotRange -> {-1, 1}, ImageSize -> 22 22, Frame -> True, AspectRatio -> 2/3];
    fig2 = Plot[Sin[x], {x, -\[Pi], 2.1 \[Pi]}, PlotRange -> {-1.2, 1.2},ImageSize -> 22 22, Frame -> True, AspectRatio -> 2/3];
    ImageDimensions@fig1
    ImageDimensions@fig2
    
  2. The margin of Framelabel and FrameTicks is also included in the calculation of ImageSize, which means two images with different Framelabel or FrameTicks may have different exact size even if their ImageSize is set to be the same. fig1 shows {484,338} while fig2 shows {323}. How to resize the images so that the exact size of image is not affect by the margin of frame ?

    ClearAll[fig1, fig2, tickX1, tickX2];
    tickX1 = Transpose[{Table[\[Pi]*i, {i, 0, 2}],Table[Style[ToString[i*2] <> "\[Pi]", 25], {i, 0, 2}]}];
    fig1 = Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotRange -> {-1, 1},ImageSize -> 22 22, Frame -> True, AspectRatio -> 2/3,FrameTicks -> {{Automatic, None}, {tickX1, None}}]
    fig2 = Plot[Sin[x], {x, 0, 2 \[Pi]}, PlotRange -> {-1.2, 1.2},ImageSize -> 22 22, Frame -> True, AspectRatio -> 2/3];
    ImageDimensions@fig1
    ImageDimensions@fig2
    

To sum up, I just want to combine several images using ImageAssemble or ImageCollege. Any solution that solve my problem is welcome. Thank you !

$\endgroup$
2
  • 1
    $\begingroup$ You mean ConformImages? $\endgroup$
    – yode
    Oct 31, 2016 at 15:15
  • $\begingroup$ yes, the same kind of thing. The actual size of different images is a problem to me. $\endgroup$
    – AchillesJJ
    Oct 31, 2016 at 16:13

1 Answer 1

4
$\begingroup$

As suggested by yode:

{fig1C, fig2C} = ConformImages[{fig1, fig2}];
ImageAssemble[{fig1C, fig2C}]

or you can use

GraphicsRow[{fig1, fig2}]

(or related GraphicsGrid if you have many plots).

$\endgroup$

Your Answer

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

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