Re: Set default options for a function
- To: mathgroup at smc.vnet.net
- Subject: [mg59231] Re: Set default options for a function
- From: "Jens-Peer Kuska" <kuska at informatik.uni-leipzig.de>
- Date: Wed, 3 Aug 2005 01:19:39 -0400 (EDT)
- Organization: Uni Leipzig
- References: <dcmu2e$gi9$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi, that is no wonder, because PlotStyle /. {options} /. Options[MultipleListSmith] will evaluate to {{Red},{Blue},{Green},{Orange}} and not to an option for MultipleListPlot of the form: PlotStyle -> {{Red},{Blue},{Green},{Orange}} You have to write PlotStyle->(PlotStyle /. {options} /. Options[MultipleListSmith]) or better {mystyle,myjoin,myshape}={PlotStyle,PlotJoined,SymbolShape} /. {options} /. Options[MultipleListSmith]; MultipleListPlot[ listaUV, PlotStyle -> mystyle, PlotJoined -> myjoin, SymbolShape ->myshape ] Regards Jens "Daniele Lupo" <danwolf_no_spam_please_ at libero.it> schrieb im Newsbeitrag news:dcmu2e$gi9$1 at smc.vnet.net... | Hi. | | I've created (after some effort), a function that plot into a Smith chart a | set of data. | | In this function, all works OK, but I'd like to set default options for | MultipleListPlot in a different way. | | My function in made in this way: | | MultipleListSmith[lista_List,options___] := | Module[{listaUV}, | ....I modify listaUV here... | MultipleListPlot[listaUV, options] | ] | | now, my data by default is created by four sets of xy data | {{data1},{data2},{data3},{data4}}, so I must to do four plots with | MultipleListPlot. | | I't works all (now...), but I'd like to create, by default, four different | styles for every plot, in this way: | | SymbolShape->None, PlotStyle->{{Red},{Blue},{Green},{Orange}}, | PlotJoined->True | | I'd like that these options are used by default, changing them when I need | other styles (considering that lista represents four data sets, by | default). | I've used the default value | | options___:{PlotJoined -> True, SymbolShape -> None, PlotStyle -> {{Red}, | {Blue}, {Green}, {Orange}}} | | But it does not work, returning the plot with default options, not mine... | | I've also tried the example shown in the mathematica book of the online | help 2.3.10, so, I've written: | | Options[MultipleListSmith] = {PlotJoined -> True, SymbolShape -> None, | PlotStyle -> {{Red}, {Blue}, {Green}, {Orange}}}; | | MultipleListSmith[lista_List, options___]:= | Module[ | ..... | MultipleListPlot[ | listaUV, | PlotStyle /. {options} /. Options[MultipleListSmith], | PlotJoined /. {options} /. Options[MultipleListSmith], | SymbolShape /. {options} /. Options[MultipleListSmith] | ] | ] | | but it returns errors to me, of this type: | | MultipleListPlot::badargs : | MultipleListPlot has been given bad arguments. Input Should be data sets | consisting of points or points with ErrorBar specifications. | | If I replace my last three arguments with options, all works fine, but I | don't have dafault values that I wants... | | Anyone can help me? | | Thanks for your answers | | Daniele |