3
$\begingroup$

I just ran into a problem with GraphicsRow. Here an example (I want to combine a BarChart and a PairedBarChart), so...

{l1, l2} = RandomInteger[#, 20] & /@ {10, 10};

and:

g1 = BarChart[l1, BarOrigin -> Left]

and

g2 = PairedBarChart[l1, l2,
  ChartLabels -> Range[20],
  AxesLabel -> {"Horizontal", "Vertical"}
  ]

Then GraphicsRow delivers:

GraphicsRow[{g1, g2}]

Output (look at the borders of GraphicsRow):

GraphicsRow unaligned

Now the graphs are not aligned, so I used an alignment (Bottom in GraphicsRow), and got:

GraphicsRow[{g1, g2}, Alignment -> Bottom]

<code>GraphicsRow</code>with alignment at bottom

O.K. the graphs are aligned, but why this large surrounding box?

Update...

If I add a frame, everything is fine???

enter image description here

$\endgroup$
4
$\begingroup$

If you use AspectRatio->Full then it works without having to use Frame nor Alignment

{l1,l2} = RandomInteger[#,20]&/@{10,10};
g1      = BarChart[l1,BarOrigin->Left,AspectRatio->Full]
g2      = PairedBarChart[l1,l2,ChartLabels->Range[20],
           AxesLabel->{"Horizontal","Vertical"},AspectRatio->Full]

Now

GraphicsRow[{g1,g2},ImageSize->700]

Mathematica graphics

fyi, I noticed with this method, if the final imagesize is small, the numerical values in the right images in the middle there (the ones from 1..20, become harder to read as they do not scale.

$\endgroup$
  • $\begingroup$ This works fine for me -so accepted as answer. But if you use Alignment->Bottom your get again the large surrounding box. What I also wonder about is that the alignment regards to the numbers at the tick-marks not the horizontal axes $\endgroup$ – mgamer Dec 10 '17 at 13:23
1
$\begingroup$

I usually use Grid. If you dont need frame just remove Frame@ in the code.

   SeedRandom[123];
{l1, l2} = RandomInteger[10, {2, 20}];

g1 = BarChart[l1, BarOrigin -> Left, ImageSize -> 350];

g2 = PairedBarChart[l1, l2, ChartLabels -> Range[20], 
   AxesLabel -> {"Horizontal", "Vertical"}, ImageSize -> 450];

Framed@Grid[{{g1, Spacer[2], g2}}, Alignment -> Bottom]

enter image description here

$\endgroup$

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.