Suppose I need to write a function to plot the real and imaginary part of some function (just an example). I want to define a function foo so that foo[f[t],{t,0,10},PlotRange->All,(some other plot options)] essentially calls
Plot[{Re[f[t]],Im[f[t]]},{t,0,10},PlotRange->All,(some other plot options)]
How to achieve that with, say, pattern matching?


ClearAll[foo]; SetAttributes[foo, HoldFirst]; foo[f_[t_], {t_, tmin_, tmax_}, opts : OptionsPattern[]] := Plot[{Re[f[t]], Im[f[t]]}, {t, tmin, tmax}, PlotRange -> All, opts]? – kglr Jan 06 '15 at 02:39foo2 = Plot[{Re[#], Im[#]}, #2, PlotRange -> All, ##3] &;? – kglr Jan 06 '15 at 02:44foo[Sin[t] + I*Cos[t], {t, 0, 10}, PlotRange -> All]does not work on my machine (output is exactly "foo[Sin[t] + I*Cos[t], {t, 0, 10}, PlotRange -> All]"). – egwene sedai Jan 06 '15 at 02:46{Re[f[t]], Im[f[t]]}withEvaluate@{Re[f[t]], Im[f[t]]}. These comments should be posted as an answer ;) – SquareOne Jan 09 '15 at 11:03