I am trying to plot the graph shown below (even arrows or lines to show important frequency points would be enough) I have been searching for hours, but I cannot find a sample code that can help me plot it. Could you help me?
1 Answers
Welcome! If you want to plot real data, you need real data. This answer assumes you wish to produce a cartoon of the depicted plot. This can be done rather easily with pgfplots, as advertised in the comments. One may define a fake peak function (which is actually not too much of a fake because this is the Breit-Wigner form of a peak), which depends on the plot variable x, and has two more parameters controlling the location and the width. If you add several of those (with prefactors fixing the heights of the respective peaks), you get
\documentclass[tikz,border=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=12cm,compat=1.16}% <- if you have an older installation, try 1.15 or 1.14
\begin{document}
\begin{tikzpicture}[declare function={%
peak(\x,\u,\v)=ifthenelse(\x>\u*(1-\v) && \x<\u*(1+\v),
-\v/(1+\v)+\v/(\v+pow((\x-\u)/(\u*\v),2)),0);}]
\begin{axis}[xmode=log,
xminorgrids,
ymajorgrids,
grid style={densely dashed,thin},
xtick={1,10,100,1000,10000,100000},
xticklabels={$1\mathsf{kHz}$,$10\mathsf{kHz}$,$100\mathsf{kHz}$,
$1\mathsf{MHz}$,$10\mathsf{MHz}$},
yticklabel=$\mathsf{\pgfmathprintnumber{\tick}}\mathsf{A}$,
ytick={0,0.8,...,8.8},
ymax=8.1]
\addplot[blue,no marks,domain=0.5:30000,samples=501]
{7.9*peak(x,130,0.1)+0.3*peak(x,170,0.2)+0.8*peak(x,220,0.1)};
\end{axis}
\end{tikzpicture}
\end{document}
If you add more peaks, you can qualitatively reproduce your screen shot. As for the timing: on a five year old MacBook pro this takes 5 seconds to compile. You could speed it up by using gnuplot but personally I find 5 seconds not too bad. There are other things you may want to add like siunits for the units and so on, but I prefer to keep this code here rather minimal.


\usepackage{pgf}). – Skillmon Nov 10 '19 at 17:00