Define function that behaves almost identically to Mathematica function

If you want to constrain it to only options from ListPlot, you could use OptionsPattern in combination with FilterRulesand Options.

myListPlot[data_, opts : OptionsPattern[]] := 
 ListPlot[data, GridLines -> {None, {data[[1]]}}, 
  FilterRules[{opts}, Options[ListPlot]]]

which results in:

myListPlot[data, PlotStyle -> Red, Joined -> True]

Mathematica graphics


The usual way to define a Wolfram Language function that takes n arguments and an arbitrary number of options is like this:

f[arg1_, ..., argn_, opts___] := ...

A little bit of pattern matching background (taken from the WL reference):

  • _ any single expression
  • x_ any single expression, to be named x
  • __ any sequence of one or more expressions
  • x__ sequence named x
  • x__h sequence of expressions, all of whose heads are h
  • ___ any sequence of zero or more expressions
  • x___ sequence of zero or more expressions named x
  • x___h sequence of zero or more expressions, all of whose heads are h