# How to plot the imaginary part of $\tan(x)^{\cos(x)}$ on the $xy$-plane?

So recently, I asked this question on Math.SE on if my thought process on how to solve the limit $$\lim_{x\to(\pi/2)^-}\tan(x)^{\cos(x)}$$ was correct, and actually, while I was solving this, I was trying to plot the imaginary part of said equation in Mathematica for practice.

I do have code for plotting the real-value part

Plot[Tan[x]^Cos[x],{x,-5,5}]


which does work as intended, however I'm confused as to how to get the imaginary plot of this function.

I have tried using

ComplexPlot[Tan[x]^Cos[x],{x,-5,5}]


but it returns the following errors:

ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
General: Further output of ComplexPlot::plld will be suppressed during this calculation.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
Out[6]= ComplexPlot[Tan[x]^Cos[x],{x,-5,5}]


I managed to fix this by adding an imaginary part to my bounds (my current code so far)

ComplexPlot[Tan[x]^Cos[x],{x,-5-5i,5+5i}]


which returns this

which looks cool, but it's not what I'm trying to do.

What I'm trying to do is this is plot the imaginary part of $$\tan(x)^{\cos(x)}$$ on the $$xy$$-plane like this (ignore the blue line):

although I don't know how to fix my code from here. So my question is:

### How do I plot the imaginary part of $$\tan(x)^{\cos(x)}$$ on the $$xy$$-plane?

Plot[Evaluate[ReIm[Tan[x]^Cos[x]]], {x, -5, 5},
PlotRange -> {All, {-5, 5}}]


• Enough Plot[Im[Tan[x]^Cos[x]], {x, 0, 2*Pi}]. Commented Dec 11, 2023 at 20:16

Since V 12.0 there is ReImPlot

ReImPlot[Tan[x]^Cos[x], {x, -5, 5},
GridLines -> Automatic,
PlotLegends -> {"Expressions", "ReIm"},
PlotRange -> {All, {-5, 5}}]


We also have AbsArgPlot which generates a plot of Abs[f] colored by Arg[f]

AbsArgPlot[Tan[x]^Cos[x], {x, -5, 5},
Epilog ->
{Dashed,
{InfiniteLine[{Pi, 0}, {Pi, 1000}],
InfiniteLine[{-Pi, 0}, {-Pi, 1000}]}},
GridLines -> Automatic,
PlotLegends -> Automatic]