Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I can't find the answer anywhere, is it [and how] possible to make a group plot of multiple polar graphs? For grouping, I use pgf.groupplot library, for polar axis, I use \begin{polaraxis} from pgf package too. But it can be another library or package.

I want to visualize polar distribution characteristics of audio signal for each third-octave band from 20 to 20.000 Hz

The target page should look somehow like this picture:

Third-octave bands

share|improve this question
1  
The groupplot library won't work here, I believe. The easiest way to do this might be to put all the axes into a single tikzpicture, and taking care of the placement manually. Could you edit your question to include a little more detail on how you want to lay out the plots, and how flexible the solution should be? –  Jake May 4 '13 at 12:11
    
If you want to show something from 20Hz to 20kHz, wouldn't a Bode plot be the way to go? Probably something like this example? –  Tom Bombadil May 4 '13 at 14:27
    
@Tom Bombadil That is a misunderstood, each frequency band [20Hz, 31.5Hz, 40Hz, ... , 16kHz, 20kHz] has its own polar plot with an angle on x-axis and a pressure level on y-axis, it can't be merged into one plot. –  Dix May 4 '13 at 14:36
    
Ah, Okay. How many of these do you need to do? So should it be fully automatic or is fine tunung by hand an option? –  Tom Bombadil May 4 '13 at 14:40
    
It's 30 plots, so if there wouldn't be another way, it's not impossible to do it manually. –  Dix May 4 '13 at 15:18
show 2 more comments

2 Answers

This solution reads the data from a file. It let's you chose haw many plots there are in a row and how they should be scaled. But it will not break across pages, so at this number of plots you should use the [p] float placement specifier:

Code

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.8}
\usetikzlibrary{pgfplots.polar}
\usepackage{pgfplotstable}
\usepackage{xifthen}

\begin{document}

\pgfplotstableread{
ang f1  f2  f3  f4  f5  f6  f7  f8  f9  f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30
-90 0.5 0.46    0.62    0.95    0.33    0.43    0.58    0.42    0.28    0.51    0.87    0.49    0.55    0.25    0.64    0.11    0.09    0.74    0.19    0.64    0.15    0.77    0.61    0.05    0.3 0.57    0.69    0.46    0.24    0.4
-60 0.73    0.47    0.56    0.63    0.57    0.73    0.43    0.39    0.66    0.24    0.62    0.56    0.88    0.35    0.36    0.77    0.87    0.29    0.33    0.91    0.74    0.58    0.46    0.16    0.8 0.91    0.44    0.91    0.82    0.43
-30 0.41    0.33    0.71    0.88    0.56    0.33    0.59    0.22    0.01    0.27    0.1 0.25    0.35    0.59    0.02    0.23    0.26    0.76    0.22    0.78    0.15    0.97    0.59    0.77    0.85    0.18    0.51    0.09    0.96    0.1
0   0.07    0.33    0.29    0.04    0.66    0.1 0.19    0.43    0.7 0.84    0.87    0.14    0.41    0.43    0.23    0.66    0.1 0.74    0.77    0.51    0.05    0.08    0.7 0.65    0.76    0.18    0.07    0.32    0.56    0.36
30  0.59    0.17    0.24    0.29    0.26    0.72    0.46    0.68    0.47    0.52    0.42    0.85    0.07    0.84    0.31    0.29    0.39    0.64    0.3 0.73    0.07    0.58    0.3 0.45    0.83    0.2 0.63    0.23    0.45    0.41
60  0.46    0.15    1   0.11    0.15    0.35    0.91    0.48    0.4 0.5 0.25    0.52    0.67    0.34    0.67    0.7 0.33    0.03    0.16    0.74    0.58    0.38    0.56    0.28    0.4 0.94    0.32    0.64    0.86    0.09
90  0.84    0.42    0.01    0.49    0.73    0.88    0.35    0.58    0.11    0.09    0.73    0.45    0.58    0.96    0.62    0.8 0.94    0.99    0.63    0.82    0.53    0.63    0.58    0.4 0.56    0.33    0.24    0.51    0.06    0.52
}\polardata

\pgfmathtruncatemacro{\plotsperrow}{6}
\pgfmathsetmacro{\scalingfactor}{0.5}

\begin{figure}[p]
\foreach \x in {1,...,30}
{   \begin{tikzpicture}[scale=\scalingfactor]
    \begin{polaraxis}[xmin=-90,xmax=90]
        \addplot table
        [   x=ang,
            y=f\x,
        ] {\polardata};
    \end{polaraxis}
    \end{tikzpicture}
    \pgfmathtruncatemacro{\mynewline}{mod(\x-1,\plotsperrow) == \plotsperrow -1 ? 1 : 0}
    \ifthenelse{1 = \mynewline}{\\}{}
}
\caption{many bogus plots}
\end{figure}

\end{document}

Output

enter image description here

share|improve this answer
    
Yes, thanks for the solution, this could be the way, in my case I wanted the data to be located all together in main .tex file, so I decided to write a 2D array of semicircles using two \foreach cycles with the plot's coordinates only in tikzpicture environment manually. –  Dix May 11 '13 at 20:07
add comment

For this case, as the best solution I have chosen manually placing the plots in tikzpicture environment. The source code is shown here and the output below.

\begin{tikzpicture}[scale = 0.63]
    \foreach \r in {0,1,2,3,4,5,6} {
        \foreach \c in {0,1,2} {
            \draw ({\c*6.5+0.5},{26-(\r+1)*4+0.5}) -- ({(\c+1)*6.5-0.5},{26-(\r+1)*4+0.5}); % x-axis
            \draw ({(\c+1)*6.5-0.5},{26-(\r+1)*4+0.5}) arc (0:180:2.75); % y-axis
            \foreach \a/\l in {30/60,60/30,90/0,120/-30,150/-60} { % angles
                \draw[black!30] ({\c*6.5+3.25},{26-(\r+1)*4+0.5}) -- ({\c*6.5+3.25+2.75*cos(\a)},{26-(\r+1)*4+0.5+2.75*sin(\a)});
                \draw ({\c*6.5+3.25+3*cos(\a)},{26-(\r+1)*4+0.5+3*sin(\a)}) node[scale=0.5] {\l°};
            }
            \foreach \b/\m in {0/0,0.25/20,0.5/40,0.75/60} { % dB
                \draw[black!30] ({(\c+1)*6.5-3.25+2.75*\b},{26-(\r+1)*4+0.5}) arc (0:180:{2.75*\b});
                \draw ({(\c+1)*6.5-3.05+2.75*\b},{26-(\r+1)*4+0.63}) node[scale=0.5] {\m};
            }
            \draw ({(\c+1)*6.5-3+2},{26-(\r+1)*4+0.27}) node[scale=0.5] {[dB]};
        }
    }
    % those have to be placed manually [or I don't know the way to automatize it]
    \coordinate[label=below:100 Hz] () at (3.25,22.6);
    \draw   (4.4,22.5) -- ...
    \coordinate[label=below:125 Hz] () at (9.75,22.6);
    \draw   (11.1,22.5) -- ...
    ... and the other frequencies
\end{tikzpicture}

Manually placed polar-axis groupplot

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.