Re: passing both arbitary and defined options
- To: mathgroup at smc.vnet.net
- Subject: [mg98482] Re: passing both arbitary and defined options
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Fri, 10 Apr 2009 04:58:30 -0400 (EDT)
On 4/9/09 at 5:56 AM, eddie at webassign.net (Eddie) wrote: >So I'm building a plotting function, and I want it to be able to >inherit the same options that a ListPlot[] command can inherit, so >my prototype looks like this: >NewPlot[data_List,options___Rule]:=Module[{},blah blah blah >ListPlot[fancy stuff,options] >] >Here's the rub, if I additionally want to create a NewPlot-specific >option, it doesn't mesh. For example: >NewPlot[data_List,OptionsPattern[{newOption->newValue}], >options___Rule] := etc >Options contains the rule for newOption when NewPlot is called with >that option utilized, and ListPlot throws an error because it's not >a recognized option for ListPlot. >Is there a way I can have my personally declared options and the >wildcard options both present and working? Is there a way to "Drop" >the rule that matches the user-defined option from 'options'? Use the function FilterRules introduced in version 6. For earlier versions of Mathematica, the same functionality can be had by loading the Utilities`FilterOptions`. See the documentation for examples and syntax.