5
$\begingroup$

ImageSize works fine as an option for Show when used in a call.

Show[image,ImageSize->100]

enter image description here

But SetOptions does not know about that:

SetOptions[Show,ImageSize->400]
SetOptions::optnf: ImageSize is not a known option for Show.

Does anyone understand this?

V11.0.1 on Win 7 x64

$\endgroup$
1
  • 3
    $\begingroup$ if you want a workaround, use something like show[x__] := Show[x, ImageSize -> 400] $\endgroup$
    – Jason B.
    Feb 28 '17 at 2:18
5
$\begingroup$

I have a vague memory of this question being asked before but I cannot find it now.

Show has no formal options; that is Options[Show] is {}. (As MB1965 just posted I see.) I think this makes sense as Show does not really have any options of its own; it instead appends the options it is given to the compound Graphics or Graphics3D that it creates. It does not make sense for it to append a large list of default parameters to everything it creates; that would defeat the purpose of the construct IMHO.

Even if we Unprotect Show and give it Options it doesn't know what to do with these; they are not applied. However because of this if we wish we can modify the function to make it append our options.

Unprotect[Show];

Show[x___] :=
  Block[{$innerShow = True},
    Show[x, Options @ Show]
  ] /; ! TrueQ[$innerShow]

Options[Show] = {ImageSize -> 222};

This is a settable option now; i.e. you can use SetOptions[Show, ImageSize -> 900] etc.

Now:

p1 = Plot[Sin[x], {x, 0, 2 Pi}];

Show[p1, Background -> LightBlue]

Rasterize[%, "RasterSize"]

enter image description here

{222, 125}

Jason B.'s recommendation of a user show replacement is of course "safer" but what's the fun in that? :^) You can give it settable Options if you wish:

Options[show] = {ImageSize -> 222};

show[x__] := Show[x, Options @ show]
$\endgroup$
5
$\begingroup$

Look at Options:

In[683]:= Options[Show]

Out[683]= {}

SetOptions only works (at least for what I've seen) when the option is represented in Options for the symbol.

Show is simply a special beast that combines the graphics objects passed with any options inserted. It does not track the entire set of options any of the graphics it knows about can take.

$\endgroup$

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.