# Polar plot using pgfplots/tikz

I would like to reproduce the figure below using pgfplots/tikz packages on Latex. I am sharing with you a .csv file to plot a similar figure. It is important to notice that y-axis are outside the plot (left side) and there are negative and positives values for radius (y-values). I've already spent a lot of time looking for a good result but I did not find anyone doing such thing. This figure is related to antenna topics.

Would someone help me on this? You can consider the y-axis part as an extra point! The diagram is already a huge contribution.

Consider the first columns as the angle and the second as the radius.

• I am confused. Is the attached image supposed to be obtained from the data in the .csv file? I ask because I get something different when plotting data from that file. I also don't understand the meaning of the vertical axis to the left either. Commented Sep 17, 2015 at 0:46
• If you've spent that much time, it would be nice if you'd share what you've got so people don't have to start from scratch. Even an unsuccessful attempt more often than not saves people trying to help you a whole lot of time.
– cfr
Commented Sep 17, 2015 at 1:25
• @GonzaloMedina do you happen to remember the data-structure? The "csv-file link" is dead. Could someone describe how the data file looked like? Commented Jun 5, 2019 at 12:24

If I understand correctly, you want all values between -40 dB and +20 dB to be plotted in the positive domain, with -40 dB being the origin of the pot. For that, you need to transform your data and then backtransform the axis labels, see Negative y value in polar plot.

For having the y axis outside the plot, you can use the approach from Gonzalo Medina's answer to Setting axis line offset?.

\documentclass[10pt,border=10pt]{standalone}
\usepackage{pgfplots}
\usepgfplotslibrary{polar}
\pgfplotsset{compat=1.12}

\begin{document}
\begin{tikzpicture}
\begin{polaraxis}[
xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
xtick={0,30,...,330},
ytick={-40,-30,...,20},
ymin=-40, ymax=20,
y coord trafo/.code=\pgfmathparse{#1+40},
rotate=-90,
y coord inv trafo/.code=\pgfmathparse{#1-40},
x dir=reverse,
xticklabel style={anchor=-\tick-90},
yticklabel style={anchor=east, xshift=-4.75cm},
y axis line style={yshift=-4.75cm},
ytick style={yshift=-4.75cm}
]
\addplot [no markers, thick, blue] table [col sep=comma, y=theta] {gain_xy.csv};
\addplot [no markers, thick, red] table [col sep=comma, y=phi] {gain_xy.csv};
\end{polaraxis}
\end{tikzpicture}
\end{document}

• That's great! I need to understand better some commands but you bring a lot of progress for me at this point @Jake. Is there a way to duplicate the y-axis, so besides 20 until -40 I can have from -40 until 20 in the lower part? Just like in the picture I gave like example. Commented Sep 17, 2015 at 12:52

Here's one option for the polar plots using pgfplots and the .csv file provided:

The code:

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

\begin{document}

\begin{tikzpicture}
\begin{polaraxis}[
y dir=reverse,
rotate=90,
xticklabel style={anchor=-\tick-90},
grid=both,
major grid style={dotted},
minor grid style={dotted},
minor x tick num=1,
minor y tick num=1,
xtick={0,30,...,330},
ytick={0,10,...,60},
yticklabels={}
]
\addlegendentry{$E_{\theta}$};
data cs=polar,
thick,
red,
samples=200
data cs=polar,
blue,
thick,samples=200
\addlegendentry{$E_{\phi}$};