0
$\begingroup$

I am trying to combine the following two plots using Grid option. The problem in that in the combined figure, the Legends appear larger and spoil the look of the entire figure.

    legendPS1C1 = 
  With[{x = 0.005}, 
   LineLegend[{Directive[Blue, Thickness[x]], 
     Directive[Red, Dashed, Thickness[x]]}, {"Sin(x)", "Cos(x)"}, 
    LegendMarkerSize -> {{30, 2}}]];

legendPS2C2 = 
  With[{x = 0.005}, 
   LineLegend[{Directive[Purple, DotDashed, Thickness[x]], 
     Directive[Black, Dotted, Thickness[x]]}, {"Sin(x)", "Cos(x)"}, 
    LegendMarkerSize -> {{30, 2}}]];

A = Plot[{Sin[x], Cos[5 x]}, {x, -\[Pi], \[Pi]}, PlotRange -> All, 
  PlotStyle -> {{Blue, Thickness[0.005]}, {Red, Dashed, 
     Thickness[0.005]}}, Axes -> False, Frame -> True, 
  PlotLegends -> Placed[legendPS1C1, Top], GridLines -> {{0}, {0}}, 
  FrameLabel -> {"x", Rotate["Sin(x), Cos(x)", 0 Degree]}]

B = Plot[{Sin[2 x], Cos[8 x]}, {x, -\[Pi], \[Pi]}, PlotRange -> All, 
  PlotStyle -> {{Purple, DotDashed, Thickness[0.005]}, {Black, Dashed,
      Thickness[0.005]}}, Axes -> False, Frame -> True, 
  PlotLegends -> Placed[legendPS2C2, Bottom], GridLines -> {{0}, {0}},
   FrameLabel -> {"x", Rotate["Sin(x), Cos(x)", 0 Degree]}]

grid = Grid[{{A}, {B}}, Spacings -> {2, 2}]
$\endgroup$
  • 2
    $\begingroup$ Another way to see the problem is to consider that the plots should not be reduced in the combined figure. In that case the solution is : grid =Style[ Grid[{{A}, {B}}, Spacings -> {2, 2}],ImageSizeMultipliers->{1, 1}] $\endgroup$ – andre314 Oct 11 '17 at 18:21
  • $\begingroup$ Thanks @andre. It worked for me. $\endgroup$ – Jee Oct 11 '17 at 18:53
  • $\begingroup$ see also: ImageSizeMultipliers on mma.se $\endgroup$ – kglr Oct 11 '17 at 19:39

Your Answer

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

Browse other questions tagged or ask your own question.