0

I would change the formula that let this TiKZ function to draw frequency wave.

\documentclass{standalone}

\usepackage{tikz}

\usepackage{pgfplots}

\pgfplotsset{compat=1.15}

\begin{document}

    \newcommand{\xmax}{14}
    \newcommand{\fmin}{(pi/3)}
    \newcommand{\fmax}{(2*pi)}
\begin{tikzpicture}[domain=0:\xmax, samples=500]

    \draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );

\end{tikzpicture}
\end{document}

I think I understand how it works. But I still can't obtain the result I would.

I think, the draw function

\draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );

can draw the wave without a cycle (foreach or similar), because the \begin{tikzpicture}[domain=0:\xmax, samples=500] parameters (domain= 0:\xmax) tell to the \begin{tikzpicture} to repeat the \draw from o to \xmax

But, I'm not able to change the \draw to obtain an image that start from hight frequency to low.

I don't understand the trigonometric funcion.

Can someone help me to modify this function to obtain that?

RenatoP
  • 791

1 Answers1

2

As long as there is no text etc. simply use xscale=-1 to invert left and right

\documentclass{standalone}

\usepackage{tikz}

\usepackage{pgfplots}

\pgfplotsset{compat=1.15}

\begin{document}

    \newcommand{\xmax}{14}
    \newcommand{\fmin}{(pi/3)}
    \newcommand{\fmax}{(2*pi)}
\begin{tikzpicture}[domain=0:\xmax, samples=500,xscale=-1]

    \draw[ultra thick, red] plot (\x, {sin(deg(exp(ln(\fmin)+\x/\xmax*(ln(\fmax)-ln(\fmin)))*\x))} );

\end{tikzpicture}
\end{document}

enter image description here


If you can use the axis environment from pgfplots, you can also reverse the direction of the x axis:

\documentclass{standalone} 
\usepackage{pgfplots}

\begin{document}

  \begin{tikzpicture}
    \begin{axis}[
      samples=1000,
      x dir=reverse,
      hide axis
    ]
      \addplot[domain=0:14] (x, {sin(deg(exp(ln((pi/3))+x/14*(ln((2*pi))-ln((pi/3))))*x))} );

    \end{axis}
  \end{tikzpicture}

\end{document}

enter image description here

(Needs pgfplots > 1.3)