0

I defined a new FrameTicksStyle, but their size is changed when more than one figure are stacked vertically. However, the size is accepted when figures are stacked horizontally. Kindly, check the code below:

1- I defined the PlotTheme with the new style

s[j_, tl_] := Table[{j i, j i, {0, -tl}, Black}, {i, -100, 100}]; 
p[j_, ts_] := Table[{j i/5, "", {0, -ts}, Black}, {i, -99, 99}]; 
ticks[j_, tl_, ts_] := ArrayFlatten[{{s[j, tl]}, {p[j, ts]}}];

Themes`AddThemeRules["mysty", 
  LabelStyle -> {FontSize -> 18, Black, 
    FontFamily -> "Times New Roman"}, 
  FrameStyle -> Directive[{Black, Thickness[0.004]}], Frame -> True, 
  FrameTicksStyle -> {{Directive[Black, Thickness[0.003]], 
     Directive[White, Thickness[0.003]]}, {Directive[Black, 
      Thickness[0.003]], Directive[White, Thickness[0.003]]}}];

2- This the part that helps stacking the figures

tb := 2; sd = 1;
Options[plotGrid] = {ImagePadding -> 0};
plotGrid[l_List, w_, h_, opts : OptionsPattern[]] := 
 Module[{nx, ny, sidePadding = OptionValue[plotGrid, ImagePadding], 
   topPadding = tb, widths, heights, dimensions, positions, 
   frameOptions = 
    FilterRules[{opts}, 
     FilterRules[Options[Graphics], 
      Except[{ImagePadding, Frame, FrameTicks}]]]}, {ny, nx} = 
   Dimensions[l];
  widths = (w - 2 sidePadding)/nx Table[1, {nx}];
  widths[[1]] = widths[[1]] + sidePadding;
  widths[[-1]] = widths[[-1]] + sidePadding;
  heights = (h - 2 sidePadding)/ny Table[1, {ny}];
  heights[[1]] = heights[[1]] + sidePadding;
  heights[[-1]] = heights[[-1]] + sidePadding;
  positions = 
   Transpose@
    Partition[
     Tuples[Prepend[Accumulate[Most[#]], 0] & /@ {widths, heights}], 
     ny];
  Graphics[
   Table[Inset[
     Show[l[[ny - j + 1, i]], 
      ImagePadding -> {{If[i == 1, sidePadding, sd], 
         If[i == nx, sidePadding, sd]}, {If[j == 1, sidePadding, tb], 
         If[j == ny, sidePadding, topPadding]}}, AspectRatio -> Full],
      positions[[j, i]], {Left, Bottom}, {widths[[i]], 
      heights[[j]]}], {i, 1, nx}, {j, 1, ny}], 
   PlotRange -> {{0, w}, {0, h}}, ImageSize -> {w, h}, 
   Evaluate@Apply[Sequence, frameOptions]]]

3- Finally, I stacked the figures

fm0 = Plot[{x/5}, {x, 0, 20}, PlotRange -> {0, 4}, 
  PlotStyle -> {Blue}, FrameLabel -> {"x", "Y"}, 
  FrameTicks -> {ticks[5, 0.02, 0.01], ticks[2, 0.02, 0.01]}, 
  PlotTheme -> "mysty"];
Horz=plotGrid[{{fm0}, {fm0}, {fm0}}, 500, 350, ImagePadding -> 60]
Vert=plotGrid[{{fm0, fm0, fm0}}, 350, 500, ImagePadding -> 60]

enter image description here

enter image description here

MMA13
  • 4,664
  • 3
  • 15
  • 21
  • I've read your question a few times and I don't understand what problem you want help with. – mikado Jun 30 '19 at 13:50
  • @mikado Well, sorry for that. Simply, the FrameTicks on the y-axis are very large compared to those on x-axis when the figures are stacked vertically, see second figure. While in the first figure the size of FrameTicks on both axes are consistent. I want the size of the FrameTicks on both axes in Fig. 2 to be similar to those in Fig.1 – MMA13 Jun 30 '19 at 15:06
  • I think the problem is that tick length (as specified) is scaled to the size of the axes. When you change the size of the axes, you get a corresponding change in the tick length. – mikado Jun 30 '19 at 19:54
  • 1
    Is it possible to avoid that? – MMA13 Jul 01 '19 at 04:22
  • 1
    I think the problem is using AspectRatio -> Full. Try Plot[Sin[x], {x, 0, 10}, AspectRatio -> Full, Frame -> True]. – Greg Hurst Jul 01 '19 at 23:01
  • 1
    And based on https://mathematica.stackexchange.com/questions/19656/, I think this is a bug. It looks like this answer on the page provides a workaround. – Greg Hurst Jul 01 '19 at 23:34

0 Answers0