4

So I have this 3d polar plot describing an antenna's radiation pattern, generated with the data exported from the simulation program. The spike in the middle is the main feature of the radiation pattern, but it should be more rounded.

This is caused by the fact that the maximum angular resolution is of 3 degrees (x and y axes are in degree). A smaller resolution (2 or 1 degree) causes the TeX capacity exceeded error.

However, I'll be happy to improve the resolution only in the proximity of the peak (-15 < phi, theta < 15), but I'm struggling with the data files.

enter image description here

The MWE is the following:

\documentclass{standalone}

\usepackage{pgfplots,siunitx}
\usepgfplotslibrary{dateplot,polar,units,external}
\pgfplotsset{compat=newest}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
        colorbar,
        data cs=polar,
        ymin=-50, ymax=50,
        xmin=-50, xmax=50,
        zmin=0, zmax=31,
        xlabel={$\phi$},
        x unit=\si{\degree},
        ylabel={$\theta$},
        y unit=\si{\degree},
        zlabel={Directivity},
        z unit=\si{\dB},        
        point meta min=0, point meta max=31,
        unit vector ratio*=1 1 2,
        z buffer=sort,
        view={45}{30},
        width=20cm
        ]
\addplot3[surf, fill=white, mesh/ordering=y varies, mesh/rows=61] %
table[x index={1},y index={0},z index={2}]{8x8-ful-arr-good-3.txt};
\end{axis}
\end{tikzpicture}
\end{document}

and the data files are:

I'm looking for a way to improve the plot in the desired region using pgfplots. Is there a way to combine the two files?

  • 2
    sorry, posted prematurely (pressed enter by mistake). wait some minutes for the full question – Alessandro Cuttin Oct 3 '14 at 12:09
  • Done! question is complete – Alessandro Cuttin Oct 3 '14 at 13:15
  • Btw, I already increased the LaTeX memory: main_memory = 12000000 – Alessandro Cuttin Oct 3 '14 at 13:19
  • If using LuaLaTeX is an option (it has dynamic memory allocation), your MWE successfully compiles on my system with either data file. – Paul Gessler Oct 3 '14 at 13:21
  • 1
    Side note: PGF has a memory leak which causes !TeX capacity exceeded, sorry [save size=100000] for huge mesh/surface plots. I am about to repair it. Workarounds are only to lower the resolution or to use shader=interp. – Christian Feuersänger Oct 4 '14 at 13:45
3

You can filter out points that you do not need by means of x filter and/or y filter. In order to keep the mesh structure intact, you have to respect two items:

  1. make sure that you assign unbounded coords=jump
  2. make sure that points which should be discarded receive "nan" (and not an empty value).

Violating any of these items would destroy the mesh structure.

Here is what I get:

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\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,
        x filter/.code={%
            % PHI:
            \ifdim-15pt>#1pt
                \def\pgfmathresult{nan}%
            \fi
        },
        y filter/.code={%
            % THETA
            \ifdim#1pt>15pt
                \def\pgfmathresult{nan}%
            \fi
        },
        unbounded coords=jump,
        ]
\addplot3[surf, fill=white, mesh/ordering=y varies, mesh/rows=37] table[x index={1},y index={0},z index={2}]{polar.dat};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Some notes:

  1. I used your data file from Pgfplots closes paths in polar plot .
  2. The x filter seems to have no effect... you may want to tune that stuff based on your data file.
  3. The filters in my example work by means of TeX primitives, i.e. by means of \ifdim<dimension1> <operation> <dimension2>. Since the numbers in this context have no dimension, I have to append "pt" artificially. This approach has restricted accuracy and number range < 16384, but it works for this picture.
  4. \if<condition> \else \fi is the TeX primitive for conditionals and \def\pgfmathresult{nan} overwrites the result with "nan".
  5. There is a hole in some slice and I suspect your condition " (-15 < phi, theta < 15)" might need some modification -- either because I used the wrong data file or because it really needs different arguments.

References: see the pgfplots manual, especially the documentation for unbounded coords .

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.