[Tex/LaTex] Drawing a Zero Pole plot

pgfplotstikz-pgftikz-styles

I'm trying to draw a zero-pole plot for use with some filter design. Since i couldn't find any standard way to go about this, I tried using the polar library of PGFPlots. I'm having some trouble, however. The first plot i did turned out decently, with only poles in it. When i try to add some zeros though, its missing part of the marker used to denote the position.

\begin{tikzpicture}
\begin{polaraxis}[enlargelimits=false, % axis x line = bottom, axis y line=right,
% height=5cm, width=5cm, 
ytick={1}, %axis y line*=none, 
yticklabels={},
xtick={0,45,90,135,180,225,270,315,360},
%xticklabels={},
%separate axis lines=true,
every outer x axis line/.append style={color=red, opacity=0, fill opacity=0},
every outer y axis line/.append style={color=red, opacity=0, fill opacity=0},
xticklabels={0,
$\frac{2\pi}{8}$,
$\frac{4\pi}{8}$,
$\frac{6\pi}{8}$,
$\frac{8\pi}{8}$,
$\frac{10\pi}{8}$,
$\frac{12\pi}{8}$,
$\frac{14\pi}{8}$}
]
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(0,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(2*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(4*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(6*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(8*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(10*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(12*pi/8,0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=o}] coordinates{(14*pi/8,0.9564)};

    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(0,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(2*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(4*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(6*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(8*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(10*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(12*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={color=black, mark=asterisk}] coordinates{(14*pi/8,2-0.9564)};
    \addplot+[data cs=polarrad,mark options={fill opacity=00, opacity=00, mark=*}] coordinates{(0,1)};
\end{polaraxis}
\end{tikzpicture}

After some testing it seems i get at problem whenever i go above 5 markers. Anything above that, and some of them don't get rendered properly.

Edit: It was a problem with linestyling. I didn't explicitly set it to solid, so it changed after a while. Fixed it now.

Best Answer

The problem with the partially drawn markers occurs because you used \addplot +, with the + indicating that the normal plot style list is still going to be used. In the default style list, plots number 6 to 10 are drawn using the option dashed, every mark/.append style=solid, so the lines are dashed, but the markers are drawn solidly. Since you use the option mark options={...}, you're resetting the every mark style, so dashed now also applies to the markers (which you clearly don't want).

So either you could add the option solid to your mark options, or you could solve the whole thing much more elegantly using only two addplot commands:

\addplot [
        data cs=polarrad,
        mark=o,
        only marks,
        samples=8,
        domain=0:14*pi/8
    ] {0.9564};

will plot eight hollow circles at equally spaced positions between the angles 0 and 14*pi/8. Since I didn't use \addplot +, the line style will be set to black, solid automatically (this is the TikZ default). A similar plot command can be used for drawing the asterisks.

Also note that you don't have to provide the whole xtick list explicitly. You can just say xtick={0,45,...,315}: The first two entries determine the starting point and the increment of the list, and the last entry determines the end.

\documentclass{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}

\begin{document}


\begin{tikzpicture}
\begin{polaraxis}[enlargelimits=false,
ytick={1},
yticklabels={},
xtick={0,45,...,360},
every outer x axis line/.append style={transparent},
every outer y axis line/.append style={transparent},
xticklabels={0,
$\frac{2\pi}{8}$,
$\frac{4\pi}{8}$,
$\frac{6\pi}{8}$,
$\frac{8\pi}{8}$,
$\frac{10\pi}{8}$,
$\frac{12\pi}{8}$,
$\frac{14\pi}{8}$},
]
    \addplot [
        data cs=polarrad,
        mark=o,
        only marks,
        samples=8,
        domain=0:14*pi/8
    ] {0.9564};

    \addplot [
        data cs=polarrad,
        mark=asterisk,
        only marks,
        samples=8,
        domain=0:14*pi/8
    ] {2-0.9564};
\end{polaraxis}
\end{tikzpicture}


\end{document}
Related Question