2

Everywhere on the web, and in this forum, tells me pfgplot plots trig functions in degrees, which is what I'm after.

Here is the code for my graph:

\begin{figure}[H]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
    domain=1:20000,
    xmode=log,
    xlabel=Frequency (Hz),
    ylabel=Phase shift (\degree),
    ]
    \addplot[mark=none, samples=100, red] function {atan(-2*pi*0.001*x)};
    \end{axis}
    \end{tikzpicture}
    \caption{Transfer function with multiple values of $RC$}
\end{figure}

And the result, which as you can see, is in radians (otherwise it would stretch to minus 90). result

How can I plot in degrees?

  • Your arguments for atan make little since. – John Kormylo Jan 24 '15 at 16:42
  • 1
    @JohnKormylo they make a lot of sense when you're analyzing the phase of a passive filter... – ACarter Jan 24 '15 at 16:54
  • Right, the 2\pi is to convert frequency from Hz to redians. So the ratio of imaginary and real amplitudes is actually S for this case (pure inductor). – John Kormylo Jan 24 '15 at 21:09
  • Nah 2\pi is angular frequency to Hz :P – ACarter Jan 25 '15 at 12:12
3

When you use \addplot [...] function {...} it uses gnuplot on the terminal, which uses radians for trigonometric functions, as noted in Section 4.3.5 of the pgfplots manual.

To use the pgf computation engine, remove the word function (or replace it with expression):

\documentclass{standalone}
\usepackage{pgfplots,siunitx}
\pgfplotsset{compat=1.11}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[
    domain=1:20000,
    xmode=log,
    xlabel=Frequency (\si{\hertz}),
    ylabel=Phase shift (\si{\degree}),
    ]
    \addplot[mark=none, samples=100, red] {atan(-2*pi*0.001*x)};
    \end{axis}
    \end{tikzpicture}
\end{document}

enter image description here

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.