I have a function which plots a response behavior of model variables holding a reference value constant (the green dot in the examples below) over a common PlotRange (achieved by plotting the functions and extracting the AbsoluteOptions). As we can see below, the FrameTicks chew up a lot of screen real estate if I have the plots laid out as a row.
What I’d like to do is to have the automatically generated FrameTicks on the leftmost graphic and the others implicitly sharing the tick labels.
I'd prefer to keep the subplots separate to allow users to enable FrameTicks on the x-axis.
Any suggestions?
SOLUTION:
I kept searching Stack Exchange and stumbled upon this post
Exporting an image so that the PlotRange has a fixed size in the output
which offered the magic ju-ju incantation of "ImageSize → Automatic → size" which seems to specify the plot ImageSize rather than the plot plus ticks & labels.
If we continue with kglr's example and define
tickstyles = Join[
{{{Automatic, None}, {None, None}}},
ConstantArray[{None, None}, {3}]
]
as well as tap into Okkes' suggestion of ImagePadding
paddingSet = Join[
{{{Automatic, 3}, {Automatic, 10}}},
ConstantArray[{{3, 3}, {Automatic, 10}}, {3}]
]
Then executing
Grid[{
Plot[
#, {x, 0, 2 Pi},
Frame -> True, PlotStyle -> #2,FrameLabel -> #3, FrameTicks -> #4,
ImageSize -> Automatic -> 75,
GridLines -> Automatic, PlotRange -> {-20000, 20000},
ImagePadding -> #5
] & @@@ Transpose[{functions, styles, labels, tickstyles, paddingSet}]},
Spacings -> {0, 0}]
Results in an acceptable output of:
The downside is that I don't have total control of the aggregated ImageSize since the FrameTicks and FrameLabels are "off-budget"; however, that is not an issue for my application.
In contrast, if we were to specify only ImageSize → 75, we would get the standard-issue ugliness.
In the interests of completeness, my approach is to generate a plotSet of the graphics and extract the PlotRange out of the resulting graphics and use Show to apply the result to the plotSet, e.g.,
If[commonPlotRange && MatchQ[plotRange, All | Automatic],
plottedResponseRange = {Min@#3, Max@#4} & @@ Transpose[
Flatten@AbsoluteOptions[plotSet, PlotRange] /. Rule[
PlotRange, rng_] :> Flatten[rng]
];
plotSet = Show[#, PlotRange -> {All, plottedResponseRange}] & /@ plotSet];
Once the magic incantations have been discovered, life becomes much easier!
Thanks much,
Mark.