I have this tikzpicture/pgfplot (see below). I have a few questions about it.

  1. How do you put the x-labels (101, 102 and so on) on top of the x-axis?
  2. How do you point the y-axis downwards (the arrow below)?
  3. How do you place an x-label at the green vertical (at 1591Hz)?
  4. How can you put extra ticks on the y-axis without a label (eg. every unit a tick, only every third unit a label)?
  5. With those extra ticks from former question, how do you place gridlines alongside of them?
  6. Is it posssible to put a dot or a cross on the intersection red-green?
  7. Can I also put an arrow pointing to that intersection point with a text label?
  8. When I start the domain at 10 instead of 1, or when I use xmin=10, I get a white region between the y-axis and the plot/grid. How can you avoid this. I would like this plot starting with 101 at the y-axis.

Thanks very much in advance!

      axis lines=middle,
      ylabel style={at={(ticklabel* cs:1)},anchor=east},
      xlabel style={at={(ticklabel* cs:1)},anchor=south},
      xtick style={above=1cm},
    \addplot[no marks, blue] {20*log10(1/sqrt(1+(2*\pi*\R*\C*x)^2))};
%    \addplot+[no marks, green] {20*log10(1/sqrt(1+1/((2*\pi*\R*\C*x)^2)))};
    \addplot+[no marks, red] {-3};
    \addplot+[no marks,green!50!black] coordinates{(\Fc,\dBmax) (\Fc,\dBmin)};

enter image description here

  • your code is not compileable – AndréC Mar 3 at 9:02
  • I changed the code a little, should compile. – Guido VDV Mar 3 at 9:11
  • 2
    Normally, each question should be one and only one problem and not several as you did because it makes it easier for people with the same problem to find it. Problem #2 has several answers on this site, old answers that no longer apply to the latest version of pgfplots. So ask a new question and clearly specify the solutions you have tried that have not solved this problem. – AndréC Mar 3 at 16:57

edit: like this (solved almost all your questions ... )?

enter image description here

(red lines indicate text borders)


    \begin{tikzpicture}[pin edge={Latex-,black}]
\begin{semilogxaxis}[                             % <---
    width=\linewidth,height=6cm,                  % <---
    title style = {at={(0.5,1.2)},font=\itshape}, % <---
    axis x line=top,                              % <---
    axis y line=left,                             % <---
    ymin=\dBmin, ymax=\dBmax,
    ylabel={$A_v$ (\si{\decibel})},               % <--- 
    ylabel style={at={(-0.07,0.5)}},              % <---
    ytick={\dBmin,\dBmin+3,...,\dBmax},           % <===
%   ytick={\dBmin,\numexpr\dBmin+3\relax,...,\dBmax}, % alternatively, 
    xlabel={$f$ (\si{\hertz})},
    xlabel style={at={(0.5,1.1)}},
    extra x tick style={% changes for x extra ticks % <===
        tick label style={font=\footnotesize,text=green!50!black}, % <===
        grid style={semithick,green},               % <===
    extra x ticks={1591},                           % <=== 
    extra x tick labels={1591},                     % <===
    minor y tick num=2,                             % <===
    no marks]
    \addplot[blue] {20*log10(1/sqrt(1+(2*\pi*\R*\C*x)^2))};
    \addplot[red]  {-3};
    \node[circle,fill, inner sep=1pt,
          pin=45:$f_c$] at (1591,-3) {};            % <===


  • tikz libraries should always be loaded in document preamble
  • pgfplots load tikz, so it is not necessary to load it (/again)
  • better than scaling diagram is to prescribe its width, for example to be equal to text width
  • +1: $f$ in Hz (Hz upright) would be even nicer :) – Dr. Manuel Kuehner Mar 3 at 10:01
  • 1
    @Dr.ManuelKuehner, you are right. i will correct asap (with some other small glitches ...). – Zarko Mar 3 at 10:03
  • Have you had a look at the libraries you are loading and checked which of those are really needed? And \def\pi{3.14159}, really? – marmot Mar 3 at 16:55
  • @marmoth, i my mwe i only use arrows.meta for pin edge, all other i left because op have them in his mwe. it might be better to erase them ... ok. i delete all not used. thank you for point me on this. – Zarko Mar 3 at 17:00
  • @marmoth I'm just learning to use tikz and pgfplots so I'm messing with all kind of settings. Pi is the least of them, so I just define it instead of searching for another solution (don't have much time). This picture is just a part of a larger document, so the other libraries I use in other parts, didn't filter them out. – Guido VDV Mar 3 at 18:09

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.