I have two ArrayPlots that I would like to align but my "tweaking" failed yet. I would like each "row" to be aligned.

lista = RandomReal[{0, 1}, 10];
listb = Table[RandomReal[{0, 1}, 10], {1000}];

Row[{ArrayPlot[{Table[0, {Length@lista}], lista}\[Transpose], 
                Frame -> False,
                AspectRatio -> 6/1, 
                ImageSize -> {100, 700}], 
               AspectRatio -> 3.5/6, 
               ImageSize -> {1200, 700}, 
               Frame -> False]}]

enter image description here

  • $\begingroup$ @500 Hi 500! What are those plots? $\endgroup$ – Dr. belisarius Apr 10 '12 at 17:55
  • $\begingroup$ @belisarius. Effect of a basis at first. But just cool things I find :-) Please check : leah.psych.nyu.edu/~laehNYU/main.html I am sure you will understand a lot of other questions ;-) I just really love "visual abstraction". $\endgroup$ – 500 Apr 11 '12 at 0:23
  • $\begingroup$ Damn! You are playing! :D ... nice work! $\endgroup$ – Dr. belisarius Apr 11 '12 at 0:58
  • $\begingroup$ @belisarius, Thank You :-) $\endgroup$ – 500 Apr 11 '12 at 16:19

In this particular instance, you can align the two array plots within a row by specifying each ImageSize to have the form {Automatic, h}, for some common h, and also making PlotRangePadding and ImagePadding both be none, like so:

  ArrayPlot[List /@ lista, ImageSize -> {Automatic, 250}, 
   Frame -> False,
   PlotRangePadding -> None, ImagePadding -> None],
  ArrayPlot[Transpose@listb, AspectRatio -> 1/GoldenRatio,
   ImagePadding -> None, PlotRangePadding -> None,
   ImageSize -> {Automatic, 250}, Frame -> None]}

This yields:

enter image description here


Simply use the options ImageSize -> {Automatic, 300}, PlotRangePadding -> 0 in both plots. Adjust the height to your liking, 700 pixels is much too large for my screen, so I used 300. If you have labels/axes, also set ImagePadding to a non-Automatic value.

  • $\begingroup$ Can you check if it's a dupe of the above two questions I linked to? I don't have an mma to test. $\endgroup$ – rm -rf Apr 10 '12 at 15:43
  • $\begingroup$ At least on my machine, I still needed to set ImagePadding without frames or axes. $\endgroup$ – Pillsy Apr 10 '12 at 15:47
  • $\begingroup$ @R.M Well, it's closely related, but I wouldn't close as a dupe this time ... my question was focusing on making sure that both graphics fit tightly in their cells, while the more recent question needs ImagePadding, while here PlotRangePadding is the key. $\endgroup$ – Szabolcs Apr 10 '12 at 15:53
  • $\begingroup$ @Pillsy On WinXP it works fine without an explicit ImagePadding (there's a margin but they're the same for the two figures), but yes, I can imagine that it is fragile without that. $\endgroup$ – Szabolcs Apr 10 '12 at 15:53
  • $\begingroup$ +1 It is what I was going to answer, and looks good enogh in Mma 8.0.0 Win Xp $\endgroup$ – Dr. belisarius Apr 10 '12 at 17:54

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.