I was trying to write my own plot function taking as unit size cm instead of points. I've tried
Options[MyPlot] = Options[Plot];
SetOptions[MyPlot, ImageSize -> {8.22, 5.03}];
MyPlot[fun_, int_, opts_: OptionsPattern[]] := {fun, int,
ImageSize -> OptionValue[MyPlot, opts, ImageSize]*72/2.54};
Plot @@ MyPlot[Sin[2 \[Pi] x], {x, 0, 1}, ImageSize -> 10]
and with
Options[MyGraphics] = Options[Graphics];
SetOptions[MyGraphics, ImageSize -> {8.22, 5.03}];
MyGraphics[prims_, opts_: OptionsPattern[]] := {prims,
ImageSize -> OptionValue[MyGraphics, opts, ImageSize]*72/2.54};
Graphics@@MyGraphics[Rectangle[]]
the error: OptionValue::rep: "OptionsPattern[] is not a valid replacement rule." came out.
Where am I wrong? It seems I am a bit confusing on the way to use OptionsPattern[] and using _
or __
in the function arguments before the opts.
Thanks!