I'm trying to plot simple Bode plots using pgfplots. After much research, I discarded the package Bodegraph due to its bad documentation and a lot of troubles with the gnuplot. So, I'm using an axis environment with the logarithmic x-axis activated. The next code is sample example of a tikzpicture that shows the problem.
\begin{tikzpicture}
\begin{axis}[
width=0.8\linewidth,
height = 3cm,
xmode = log,
axis x line*=box,
axis y line*=box,
xmin=1e-2, xmax=1e2,% range for the x axis
ymin=-100, ymax = 100,
scale only axis ,
ytick distance=40,
xmajorgrids = true,
ymajorgrids = true,
title = Fase,
ylabel = $\phi$,
xlabel = $\omega$
]
\addplot[smooth,
blue,
ultra thick,
mark=none,
domain=1e-2:1e2,
samples=400,
trig format plots = deg]
{atan((2*0.1*(x/2))/(1-(x/2)^2))};
\end{axis}
\end{tikzpicture}
The problem is that I get the following wrong plot:
What I'm expecting to get is something like:
Please, notice that I'm using the trig format plots=true
to set degrees for the trigonometric functions. Can anybody help me out? This is just the phase angle plot of a second order system.
Thanks in advance
restrict y to domain=[min,max]
keyword. You need to have at least one point outside the clip region to interpolate correctly. See tex.stackexchange.com/questions/324646/…atan2
is undefined so a default value1
is substituted. It raise errors because1
is not a floating number.