0
$\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$
  • 1
    $\begingroup$ Take a look at OptionsPattern, FilterRules and many related topics here. $\endgroup$ – Kuba Aug 17 '16 at 15:36
  • 1
    $\begingroup$ See the examples here and here $\endgroup$ – Jason B. Aug 17 '16 at 15:40
5
$\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, privacy policy and cookie policy

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