4
$\begingroup$

I need to put letters (A), (B) etc at right top corner of different framed plots joined using Show in one big figure. So at all plots letters should be placed at the same distance from top and left axis of the frame:

enter image description here

I tried to use Epilog but the axis scales of all plots are different, so it does not work well. Is it possible to solve this issue in simple way?

$\endgroup$
  • 1
    $\begingroup$ something like Legended[BarChart[RandomInteger[10, 10], ImageMargins -> {{5, 0}, {0, 0}}, PlotRange -> All, Frame -> True, AspectRatio -> 1/2, ImageSize -> 600], Placed[Style["A", 24, "Panel", Background -> Transparent], {{Right, Top}}]]? $\endgroup$ – kglr Dec 29 '17 at 13:18
  • $\begingroup$ @kglr Almost! It is too close to the corner. Is it possible to get more space from top and right? $\endgroup$ – Филипп Цветков Dec 29 '17 at 14:16
  • 1
    $\begingroup$ you can use {Scaled[.95], Scaled[.9]} for the top plot and {Scaled[.9], Scaled[.9]} for the bottom ones in place of {{Right, Top}}. $\endgroup$ – kglr Dec 29 '17 at 14:21
3
$\begingroup$

Since there are no input graphs, I will be using the following three simulated graphs

enter image description here

In order to incorporate a letter indicator for each graph I will be using Epilog along with Inset with scaled coordinates (see Scaled).

Evaluating

Grid[
 Through[
   {{First[#], SpanFromLeft} &, Rest}[
     MapThread[plot, Transpose@args]
   ]
  ]
]

produces

enter image description here


code

(* functions used for display purposes *)
funcs = {Cos[#] - Sin[3 # - 2] &, 
  -12.1 #^3 + 10 #^2 - 3.02 # + 12 &, 
  2.1 #^4 - 3.2 #^3 + #^2 - 3.02 # + 12 &};

(* ranges used for plotting functions *)
rng = {{-2 Pi, 2 Pi}, {-4.1, 3.2}, {-2.7, 3.1}};

(* size of each plot - relative size differences are 
   important in order to produce the effect present in the question *)
sz = {Large, Medium, Medium};

(* the symbols used to index the different plots *)
sym = {A, B, C};

(* combination of expressions to be used as input -  see below *)
args = Transpose[{funcs, rng, sz, sym}];

plot[f_, rng_, sz_, sym_] := Module[{x},
  Plot[
   f[x],
   Flatten[{x, rng}],
   Frame -> True,
   Axes -> False,
   ImageSize -> sz,
   Epilog -> {Inset[Style[sym, Bold, 22], Scaled[{0.9, 0.85}]]}
   ]
  ]

Edit

Alternatively, the rhs of the Epilog option can be modified to Inset[Style[sym, Bold, 22], Offset[{-30, -30}, Scaled[{1, 1}]]] as suggested in the comments by @Carl Woll. Using Offset with Scaled provides better control over the position of the label.

$\endgroup$
  • 3
    $\begingroup$ A small tweak. I would use Offset with Scaled instead. Something like: Offset[{-30, -30}, Scaled[{1, 1}]] instead of Scaled[{0.9, 0.85}] so that the position of the label is the same distance to the top right corner for each plot. $\endgroup$ – Carl Woll Dec 29 '17 at 16:38

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.