I have the following codes:
plotContour[func_,xRange_:{-2,2},yRange_:{-2,2},opts___]:=
ContourPlot[Re[func[x+I*y]],{x,xRange[[1]],xRange[[2]]},{y,yRange[[1]],yRange[[2]]}, opts]
opts passes the optioanl arguments like ContourStyle, ImageSize to the built-in ContourPlot function. I have provided default argument values to xRange and yRange.
But now if I run the following:
plotContour[func,ContourStyle->Red]
I run into problems because it treats ContourStyle->Red as the arguments xRange, so I receive errors (Limiting value ContourStyle in ... is not a machine-sized real number.)
How should I modify the codes so that it works when I provide optional arguments but skip the arguments with default values?
OptionsPatternand friends for that. – Sascha Aug 18 '16 at 09:34name -> value. This is different from an "optional argument" with a default value, which is likex_ : 1. – Szabolcs Aug 18 '16 at 10:30