Details and Options
ResourceFunction["CombinePlots"] combines graphics expressions while trying to move labels and callouts to the front.
ResourceFunction["CombinePlots"] by default merges the primitives inside the
Prolog and
Epilog options.
ResourceFunction["CombinePlots"] can reposition frame axes, allowing the creation of plots with two x/y axes.
ResourceFunction["CombinePlots"] accepts the following options:
"CombineProlog" | True | whether to merge prologs |
"CombineEpilog" | True | whether to merge epilogs |
"AnnotationPattern" | (GraphicsGroup|Text)[___] | the pattern used to match annotations |
"AxesSides" | Automatic | on which side to put the frame axes |
ResourceFunction["CombinePlots"] effectively removes all expressions matching the pattern specified by "AnnotationPattern" and inserts them on top of the remaining primitives.
The option "AxesSides" accepts the following settings:
Automatic | do not move frame axes |
"TwoY" | move the vertical frame axis of the second plot to the right |
"TwoX" | move the horizontal frame axis of the second plot to the top |
"TwoXY" | move the bottom/left frame axes of the second plot to the top/right |
"MultiY" | use a separate vertical frame axis for each plot alternatingly adding to the left/right side |
"MultiX" | use a separate horizontal frame axis for each plot alternatingly adding to the bottom/top side |
"MultiXY" | use a separate pair of vertical and horizontal frame axes for each plot |
spec | use explicit settings for different plots |
"AxesSides" supports the same sequence specification as documented for
Spacings.
For each plot, the setting can be one of the following:
Bottom | put horizontal frame axis to the bottom |
Top | put horizontal frame axis to the top |
Left | put vertical frame axis to the left |
Right | put vertical frame axis to the right |
side→Automatic | put the frame axis onto a separate axis on the specified side |
side→i | put the frame axis onto the axis with the specified index, counting from the inside |
{sidex,sidey} | position both horizontal and vertical frame axes |
Directive[sidex,sidey] | same as {sidex,sidey} |
The option "AxesSides" settings "TwoY"/"TwoX"/"TwoXY" are effectively equivalent to settings of the form {2→spec}.
The settings "MultiY"/"MultiX" are effectively equivalent to settings of the form
{{side1→Automatic,side2→Automatic}}, and "MutilXY" is a combination of the former two.
The sides for the frame axes of plots can also be specified by wrapping plots with
Axes[plot,sideSpec], similar to how
Item works for
Grid.
The arguments of
ResourceFunction["CombinePlots"] can be (nested) lists of plots, where each level can be wrapped in
Axes[plots,sideSpec]. Deeper specifications override outer ones as necessary.
The setting of "AxesSides" applies to each argument of
ResourceFunction["CombinePlots"] as one. Use
Axes[…] type specifications for more granular control.
ResourceFunction["CombinePlots"] will use the frame axis of the first appropriate plot for each side. The values of the
FrameLabel,
FrameTicks,
FrameStyle and
FrameTicksStyle options are used to create the frame axis in the resulting plot.
ResourceFunction["CombinePlots"] effectively uses
GeometricTransformation to rescale plot contents shown on secondary axes. Additional axes beyond the first axis per side are added using
Inset.
ResourceFunction["CombinePlots"] sets
CoordinatesToolOptions to enable extraction of coordinates from any of the axes. The format is
{{{sidex,ix},{sidey,iy}}→{x,y},…}, with one entry for each unique horizontal/vertical axis combination. The
ix,iy indicate the index of the axis on the respective side.
ResourceFunction["CombinePlots"] will always return a (possibly
Legended)
Graphics expression.
If there are no labels/callouts and no prolog/epilog to combine,
ResourceFunction["CombinePlots"][args] is equivalent to
Show[args].