3

I'd like to create an antenna radiation pattern in the form of a polar plot like this one: enter image description here (image credits: C.A. Balanis; Antenna theory, analysis and design)

What I've done so far is the following code (the data file to make the example work is here):

\documentclass{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        data cs=polar,
%       restrict x to domain=0:180,
%       restrict y to domain=0:180,
        ymin=-90,
        ymax=90,
        zmax=10.8,
        ]
\addplot3[surf,fill=white] table[x index={1},y index={0},z index={2}]{subarray-3d-plot-dir.csv};
\end{axis}
\end{tikzpicture}
\end{document}

but, strangely, pgfplots closes the paths between the first and the last point, as can be seen by the resulting image:

enter image description here

My questions:

  • how to remove the segments that close the paths?
  • how to improve the mesh/surface?

Clarification: the data file comes from a simulation software, so I don't have any means to change the way data are written in it.

  • 1
    Jake, you're right. I just uploaded a link with the data. Do you think there's a better way to do it? – Alessandro Cuttin Oct 2 '14 at 13:18
  • DO you have the equation z=f(x,y) for that? – user2478 Oct 2 '14 at 14:41
  • @Herbert I'm not sure what you mean: there is no equation, the values of the three variable (theta, phi, Abs) are in the file linked in the question – Alessandro Cuttin Oct 2 '14 at 14:47
4

Two things: You need to tell PGFPlots how many rows are in each block of data by setting mesh/rows=37 (alternatively, you could insert an empty row after each block of data, but since your file is generated by an external program, that's probably not an option here). Also, you need to set mesh/ordering=y varies, since by default, PGFPlots assumes that the x coordinate varies.

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        data cs=polar,
        ymin=-180, ymax=180,
        xmin=-180, xmax=180,
        zmin=-20, zmax=11,
        unit vector ratio*=1 1 10,
        z buffer=sort,
        view={45}{30},
        width=15cm
        ]
\addplot3[surf, fill=white, mesh/ordering=y varies, mesh/rows=37] table[x index={1},y index={0},z index={2}]{data.dat};
\end{axis}
\end{tikzpicture}
\end{document}
  • Wow! Great! What about the axes of the coordinate reference system? How can they be put in the center of the radiation pattern (like the first figure)? – Alessandro Cuttin Oct 2 '14 at 15:37

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.