7

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.

Thanks in advance

csv-file link
Consider the first columns as the angle and the second as the radius.

Polar plot

  • 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. – Gonzalo Medina Sep 17 '15 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 Sep 17 '15 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? – gr4nt3d Jun 5 at 12:24
4

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. – viniciuslb Sep 17 '15 at 12:52
5

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

enter image description here

The code:

\documentclass{article} 
\usepackage{pgfplots} 
\usepgfplotslibrary{polar}
\pgfplotsset{compat=newest}

\pgfplotstableread[col sep=comma]{gain_xy.csv}{\loadeddata}

\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}$};
\addplot[
  data cs=polar,
  thick,
  red,
  samples=200
] table[x index=0,y index=1] {\loadeddata};
\addplot[
  data cs=polar,
  blue,
  thick,samples=200
] table[x index=0,y index=2] {\loadeddata};
\addlegendentry{$E_{\phi}$};
\end{polaraxis}
\end{tikzpicture} 

\end{document}

I don't understand the vertical axis to the left of the attached image.

  • The vertical axis is just a way to give a cleaner look to the diagram and at the same time to inform the scale of the plot, since each tick corresponds to a circle of magnitude. This layout is often applied to this kind of plot in antenna topics. – viniciuslb Sep 17 '15 at 13:05

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.