Skip to main content
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. EDIT As Brett Champion mentions in the comments, the default options for

System`Plot

will change if you use SetOptions on Plot. Hence, if you want your custom plot to always have the same options as Plot, use :=. I would prefer to specifically change the options for my Plot separately, so I would still use simply Set (=).

You might also want to check out this instructive question on Options in custom functions: Functions with OptionsFunctions with Options

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. EDIT As Brett Champion mentions in the comments, the default options for

System`Plot

will change if you use SetOptions on Plot. Hence, if you want your custom plot to always have the same options as Plot, use :=. I would prefer to specifically change the options for my Plot separately, so I would still use simply Set (=).

You might also want to check out this instructive question on Options in custom functions: Functions with Options

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. EDIT As Brett Champion mentions in the comments, the default options for

System`Plot

will change if you use SetOptions on Plot. Hence, if you want your custom plot to always have the same options as Plot, use :=. I would prefer to specifically change the options for my Plot separately, so I would still use simply Set (=).

You might also want to check out this instructive question on Options in custom functions: Functions with Options

added 202 characters in body
Source Link
tkott
  • 5k
  • 25
  • 44

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. TheEDIT As Brett Champion mentions in the comments, the default options for

System`Plot

won'twill change at any pointif you use (untilSetOptions on Plot. Hence, if you install a new version of MMA)want your custom plot to always have the same options as Plot, use :=. I would prefer to specifically change the options for my Plot separately, so you can safely justI would still use simply Set (=).

You might also want to check out this instructive question on Options in custom functions: Functions with Options

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. The default options for

System`Plot

won't change at any point (until you install a new version of MMA), so you can safely just use Set.

You might also want to check out this instructive question on Options in custom functions: Functions with Options

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. EDIT As Brett Champion mentions in the comments, the default options for

System`Plot

will change if you use SetOptions on Plot. Hence, if you want your custom plot to always have the same options as Plot, use :=. I would prefer to specifically change the options for my Plot separately, so I would still use simply Set (=).

You might also want to check out this instructive question on Options in custom functions: Functions with Options

Source Link
tkott
  • 5k
  • 25
  • 44

I use the first style you gave:

Options[tListPlot]=Join[
    Options[ListPlot],
    Options[tLegend],
    {
        Rule[ShowLegend,False]
    }
];

The function is then defined as

tListPlot[data_,options:OptionsPattern[]]:=...

I don't see any reason to use SetDelayed (:=) in this context. The default options for

System`Plot

won't change at any point (until you install a new version of MMA), so you can safely just use Set.

You might also want to check out this instructive question on Options in custom functions: Functions with Options