1
$\begingroup$

Suppose I have the following plotting function:

selfPlot[func_]:=Show[ContourPlot[Re[f[x+I*y]],{x,-2,2},{y,-2,2}],ContourPlot[Im[f[x+I*y]],{x,-2,2},{y,-2,2}]]

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?

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

1 Answer 1

6
$\begingroup$

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},
   opts]
selfPlot[#^2 Sin[#] &, ContourStyle -> {Red, Blue}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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