# Manipulating OptionsPatterns[]

How do you combine OptionsPatterns?

For example, I would like to have a function that can take both options that I specify, and options for all graphs:

Options[f]={"a"->b} + OptionsPattern[LogPlot]
f[...,OptionsPattern[]] := LogPlot[..., ImageSize->OptionsValue[ImageSize]]


A related question, how do I remove options from an OptionsPattern, and pass on the remainder to another function.

For example:

f[...,OptionsPattern[LogPlot]] := LogPlot[..., (* pass on all the options EXCEPT Frame *)]


Thanks for the help.

-
A somewhat related question with very good answers –  Ryogi Aug 31 '12 at 23:39
@Ryogi: Thanks! That has a great answer for me. –  Andrew Spott Sep 1 '12 at 16:34

This information is given in the tutorial Setting Up Functions with Optional Arguments. Just catch the options given to your function in a variable and use FilterRules

odeplot[de_, y_, {x_, x0_, x1_}, opts : OptionsPattern[]] :=
Module[{sol},
sol = NDSolve[de, y, {x, x0, x1},
FilterRules[{opts}, Options[NDSolve]]];
\$Failed,
Plot[Evaluate[y /. sol], {x, x0, x1},
Evaluate[FilterRules[{opts}, Options[Plot]]]]
]
]

-

For your "related question", of passing all options to LogPlot other than Frame, just set the option to the value you want, and place this first in the function call. The first occurrence of the option is used, so any use of it in opts is redundant and ignored.

f[data_, opts:OptionsPattern[]]:= LogPlot[data, Frame->False,
Evaluate[FilterRules[{opts},Options[LogPlot]]] ]

-