2
$\begingroup$

Similar to Changing the plotting order in Show, I'd like to have control over plotting order with more advanced graphics, like a Legended ListPlot with FrameLabels. Specifics aside, I've adapted the solution from the previous question for my particular case:

Show[b, a, AbsoluteOptions[a]]

which works perfectly for me, up to the text used to label the plot and axes, which prints FrameBox["Label", TraditionalForm ] as if wrapped in one too many FrameBoxes. Placing labeling within the Show also doesn't work.

My Best Answer So Far

It seems to me the most side-effect free way of Showing things is to do the following:

  1. Define desired settings in first plot (a)
  2. Define other plots (b..)
  3. Try Show[..b, a, AbsoluteOptions[a]]
  4. For side-effected options, duplicate them before AbsoluteOptions. As placing options in Show do not perform the same lower-level routines (i.e. defining lower-level options) that functions like Plot and ListPlot do, this trick allows you to set a specific option you want (like the FrameLabel text), using AbsoluteOptions as the shim to add in all the lower-level details (like plot boundaries, text positions, spacing, etc.).

This worked in my case, but still leaves me with some open questions:

  1. Where is Options better than AbsoluteOptions and vice versa?
  2. What happens if your desired option is different enough from what's specified in a (using nomenclature from above) that some of the lower-level options are incorrect? E.g. say I specified a FrameLabel that was super long in Show, but not when defining a. (this is a case I could easily test, I will do so and revise this, but I also bet that this is generally a case for potential for side-effects)

Example

Here is a faithful but reasonably minimal working example.

$\endgroup$
2
  • $\begingroup$ Can you give an example? $\endgroup$ Sep 2, 2022 at 7:39
  • $\begingroup$ Please put the code into the question to ensure that is is preserved for the future $\endgroup$
    – Lukas Lang
    Sep 4, 2022 at 9:11

1 Answer 1

1
$\begingroup$

Unless I'm missing something, the following seems to work:

GraphicsOptions[Legended[expr_, ___], rest___] := 
  GraphicsOptions[expr, rest]
GraphicsOptions[g_Graphics, rest___] := Options[g, rest]

Show[b, a$with$explicit$labels, GraphicsOptions[a$with$explicit$labels]]

enter image description here

This relies on the helper function GraphicsOptions to extract the "non-absolute" options from the potentially wrapped Graphics expression, which are then passed to Show.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.