1

I would like to create a microphone polar pattern plot that has a scale of -20 (in the center) out to +5 in steps of 5. I have found similar code but nothing that allows for the scales to be negative.
Multiple patterns will then need to added to the plot covering a few different frequencies, I have degree values (0-360) and corresponding dB values (-25 - +5).

This is what the plot should look like (though with slightly different scales):

polar_pattern_plot

The closest gnuplot I have found to this is here: How to get a radial(polar) plot using gnu plot?

Perhaps this could be modified to suit my needs?

I would also like 0 degrees to be found at the top of the plot rather than on the right.

I am new to using gnuplot so I am not particularly familiar with its code, therefore it has been difficult for me to modify the code with any great success (so far anyway).

Community
  • 1
  • 1
Lrrrence
  • 23
  • 6
  • I guess that could be modified to fit your needs. But I don't know what a microphone polar pattern should look like, maybe you can add an examplary image, an explain where you have problems when trying to modify the code from the linked question. – Christoph Sep 26 '13 at 18:22
  • The image can't be accessed: 403 Forbidden. Do you have a dataset and want to plot contours for the levels you specified? All possible ranges can of course be negative! (except when in logscale ;). Have a look at the questions [gnuplot contour line color: set style line and set linetype not working](http://stackoverflow.com/a/18881265/2604213) and [gnuplot 2D polar plot with heatmap from 3D dataset - possible?](http://stackoverflow.com/q/18792461/2604213). – Christoph Sep 27 '13 at 11:16
  • Here is another link http://commons.wikimedia.org/wiki/File:Polar_pattern_cardioid.png – Lrrrence Sep 27 '13 at 11:47

2 Answers2

1

So you want to plot a polar function, e.g. r(theta) = 1 + sin(theta).

Plotting the function is quite easy, just do

set polar
plot 1+sin(t)

A simple polar grid can be plotted with

set grid polar

but that has the raxis and the rtics on a different position than where you wanted. It is not problem to specify custom labels. But angular labels aren't supported, so you need to set them manually. And the border and the other axes and tics must be unset.

To get the very same image as you showed, use the following script:

set terminal pngcairo size 700,600 font ',10'
set output 'cardioid.png'

set angle degree
set polar
set size ratio 1
set tmargin 3
set bmargin 3

set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11

unset border
unset xtics
unset ytics

r=1
set rrange [0:r]
set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*1.05
set label '180°' center at first 0, first -r*1.05
set label '90°' right at first -r*1.05, 0
set label '270°' left at first r*1.05, 0

set for [i=1:5] label at first r*0.02, first r*((i/6.0) + 0.03) sprintf("%d dB", -30+(i*5))
unset raxis

plot 0.5*(1+sin(t)) linewidth 2 t ''

With the result:

enter image description here

That includes some offsets for the labels, which depend on the terminal, the canvas size and the font size. So you may need to adapt them.

I had to increase the top and bottom margins a bit (here by 3 character heights) in order to have enough space for the angular labels. They aren't included in the automatic margin calculations, because the don't belong to an axis.

Christoph
  • 47,569
  • 8
  • 87
  • 187
1

Unfortunately Christoph's answer is wrong.

You can see that if you check where the plot curve crosses the 5db circle.

What should be plotted is

20*log10(A+B*cos(t)) 

where A+B = 1 and A - B determines the (nominal) directivity pattern.

The first diagram seems to be for A=B=0.5 which makes for a cardioid pattern.

mnille
  • 1,328
  • 4
  • 16
  • 20
  • Yes, you are right. I got the scaling itself wrong. – Christoph Jul 18 '16 at 14:37
  • No you did not get a scaling wrong, unless a logarithmic transformation is considered scaling. – Hans Albertsson Jul 19 '16 at 06:52
  • I think the real and more general question is or should be: How do I set up a polar plot where the raxis range (rrange?) is from some negative value (-25, -90, whatever) at a small distance from the center of the circle, to 0 at the outer edge. There should be a polar grid extending from the most negative value to the outer edge/0. The thread start diagram is precisely that kind of plot. – Hans Albertsson Jul 19 '16 at 15:51