I have just worked my way through a similar problem with Grid
, so I have a handy solution (more on this below.) The solution is rather crude; I just grab the graphics from within the Labeled
wrappers and reassemble:
ClearAll[showWithin];
showWithin[first:Labeled[_Graphics, args___], rest:Labeled[_Graphics, ___]...,
opts:OptionsPattern[]] :=
Activate[Labeled[(Inactive[Show][##1, FilterRules[{opts},
Except[Options[Labeled]]]] & )[Query[All, 1][{first, rest}]], args]]
Taking a cue from Show
, only the labeling of the first item is used, and subsequent labels are ignored.
f := SortBy[Flatten[(RandomReal[#1, {5, 2}] & ) /@ {{0, 1}, {-70, -30}}, {3,2}], Last]
{DataCauchy1mA, DataCauchy5mA} = {f, f};
showWithin[
Labeled[ListPlot[DataCauchy1mA, Joined -> True,
PlotRange -> {{0, 1}, {-70, -30}}], {"V in mV", "T in s"}, {Left, Top},
RotateLabel -> True],
Labeled[ListPlot[DataCauchy5mA, Joined -> True,
PlotRange -> {{0, 1}, {-70, -30}}], {"V in mV", "T in s"}, {Left, Top},
RotateLabel -> True]
]
The original problem I was working is similar in making Show
work within a Grid
ClearAll[GridShow];
GridShow::usage := "GridShow[g1,g2,...] shows several grids of graphics combined. Grids \
of the same dimensions may be combined, or Rows and Columns of the same length.";
GridShow::argm = General::argm;
SyntaxInformation[GridShow] = SyntaxInformation[Show];
GridShow[] := Message[GridShow::argm, "GridShow", 0, 1];
GridShow[first:Grid[{{__Graphics}..}, args___], rest:Grid[{{__Graphics}..}, ___]...,
opts:OptionsPattern[]] :=
Activate[Grid[MapThread[Inactive[Show][##1, FilterRules[{opts},
Except[Options[Grid]]]] & , Query[All, 1][{first, rest}], 2],
FilterRules[{opts, args}, Options[Grid]]]];
GridShow[first:(Column | Row)[{__Graphics}, args___],
rest:(Column | Row)[{__Graphics}, ___]..., opts:OptionsPattern[]] :=
Activate[Head[first][MapThread[Inactive[Show][##1, FilterRules[{opts},
Except[Options[Head[first]]]]] & , Query[All, 1][{first, rest}], 1],
FilterRules[{opts, args}, Options[Head[first]]]]];
Well, you can see where this could go. It is simple but laborious to go through and write a new function for every wrapper that could go around Graphics
so we could thread Show
across the interior structure. Can anybody suggest a more general approach?
Labeled
objects, sinceHead@Labeled[Plot[x, {x, -3, 3}], "plot label"]
givesLabeled
. Try another method to label the plots, likeText
orInset
$\endgroup$