Suppose I have the following plotting function:


How can I modify the function so that it can accept optional arguments like ContourStyle, AspectRatio that can be passed into the built-in ContourPlot?

  • 2
    $\begingroup$ Take a look at OptionsPattern, FilterRules and many related topics here. $\endgroup$
    – Kuba
    Aug 17, 2016 at 15:36
  • 1
    $\begingroup$ See the examples here and here $\endgroup$
    – Jason B.
    Aug 17, 2016 at 15:40

1 Answer 1


You can use a BlankNullSequence to deal with the options, just like this following code

selfPlot[f_, opts___] := 
 ContourPlot[{Re[f[x + I*y]], Im[f[x + I*y]]}, {x, -2, 2}, {y, -2, 2},
selfPlot[#^2 Sin[#] &, ContourStyle -> {Red, Blue}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.