1

Edit: Question updated to address comments from Willie Wong. The directiviy pattern now plots as I've added 90 to each value. I need the y-axis to read from -N to 0 dB where N will vary, however when I do this by setting ymin=40 as per the MWE my polar plot changes shape.

I'm trying to produce a directivity pattern which will look similar to this, except I wish for my x-axis to run between -90 and 90. directivity http://www.fao.org/3/a-aa044e/AA044E47.gif However I'm struggling to get the plot set up right. I had a look around and there's a similar question, but for python. My amplitude data has a maximum value of 0 dB and min somewhere around -90 dB. When I try to plot it using the MWE below, it's just not quite right...

MWEaxis

My MWE is below. Note the contents of polartest.csv aren't really important as the axis are what's troubling me. y values extend between -90 and +90 and x values between -90 and 0

\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\pagestyle{empty}
\usepgfplotslibrary{polar}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{polaraxis}[xmin=-90,xmax=90,rotate=-90,xticklabel=$\pgfmathprintnumber{\tick}^\circ$,xtick={-90,-45,...,90},xticklabel style={anchor=-\tick-90},x dir=reverse,yticklabel style={anchor=south, yshift=-6mm},ymin=-60, ymax=0,y coord trafo/.code=\pgfmathparse{#1+60},y coord inv trafo/.code=\pgfmathparse{#1-60}]
\addplot  [no markers, blue] table [x=coord, y=ampPos, col sep=comma] {polartest.csv};
\end{polaraxis}
\end{tikzpicture}
\end{figure}
\end{document}
  • Can you edit your csv file to include some data points where the amplitude has a positive dB value? I am guessing that since you included negative dB values, the graph is actually appearing in the bottom half plane (conventionally polar plots with negative radial values plots the corresponding positive radial value with a 180 degree phase shift) – Willie Wong Jul 25 '16 at 17:36
  • 1
    alternatively, what if you plot instead of y=amp the value of y=amp+90? – Willie Wong Jul 25 '16 at 17:37
  • Question edited to respond to the advice from Willie Wong – BenK-G Jul 26 '16 at 8:07
  • 1
    This looks very similar to tex.stackexchange.com/questions/267938/…. Could you take a look to see if the answers there help? – Jake Jul 26 '16 at 8:40
  • Jake I had a look at that question before posting, but I don't think I realised how relevant it was. I've added this code to my MWE: ymin=-60, ymax=0, y coord trafo/.code=\pgfmathparse{#1+60},y coord inv trafo/.code=\pgfmathparse{#1-60} – BenK-G Jul 26 '16 at 8:55
2

Following the comments from @Jake I set-up the axis in the following way:

\begin{polaraxis}    
[xmin=-90,xmax=90,rotate=-90,xticklabel=$\pgfmathprintnumber{\tick}^\circ$,
xtick={-45,-20,0,20,45},xticklabel style={anchor=-\tick-90},x dir=reverse,yticklabel style={anchor=south, yshift=-6mm},ymin=-40, ymax=0,
y coord trafo/.code=\pgfmathparse{#1+40},y coord inv trafo/.code=\pgfmathparse{#1-40}]

This allows me to plot directivity data saved in dB values with a maximum of 0. Directivity runs from -90 to +90 degrees. Note depending on the plot change the number 40 above to the desired dyanmic range of the plot.

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.