1

I am creating a seemingly duplicate question posted by Matt in 2015, however, the answer posted by Christoph doesn't work at the moment for me, since I'm using Gnuplot 5.2.

When I use Matt's input date and Christoph's script, I end up with this result:

Picture here

As can be seen, the bottom half (3rd & 4th quadrant) of the plot is plotted, yet it should not be.

reset

set terminal pngcairo font ',10'

set polar
set angle degrees
set size ratio 1
set lmargin 8
set style line 11 lc rgb 'gray80' lt -1
set grid polar ls 11

unset border
unset tics

set xrange [-1:1]
set yrange [0:1]
set size ratio -1

r = 1
set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*1.05
set label '-90°' right at first -r*1.05, 0
set label '+90°' 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

set key outside top right

set output 'polar.png'
plot 'norm_polar_1000.txt' w lp ls 1 t '1k'

Data:

180 0.657067
172.5 0.6832
165 0.717767
157.5 0.7461
150 0.7747
142.5 0.806167
135 0.835633
127.5 0.865167
120 0.890533
112.5 0.918133
105 0.929633
97.5 0.9566
90 0.9632
82.5 0.9566
75 0.929633
67.5 0.918133
60 0.890533
52.5 0.865167
45 0.835633
37.5 0.806167
30 0.7747
22.5 0.7461
15 0.717767
7.5 0.6832
0 0.657067

To get to my own problem, I would like to get a very similar plot but with only 2nd and 3rd quadrant instead.

My code:

reset

set terminal pngcairo font ',12'

set polar
set angle degrees
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 tics
unset key

r=1
set rrange [0:r]
set xrange [-1:0]
set yrange [-1:1]


rOffset = 1.1

set rtics 0.166 format '' scale 0
set label '0°' center at first 0, first r*rOffset
set label '90°' right at first -r*rOffset, 0
set label '180°' center at first 0, first -r*rOffset

set output 'TestPolar.png'

plot 'exampleData.txt' u ($1+90):2

exampleData.txt:

10  0.1
30  0.2
50  0.3
70  0.4
90  0.5
110 0.6
130 0.7
150 0.8
170 0.9

Current resulting picture here

Any ideas?

halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

1

It looks to me that gnuplot's trange in 5.2 is always in radians rather than degrees, even if the data itself is in degrees. That seems like a bug but you can work around it.

In 5.2 do not set xrange or yrange to limit data in polar mode; use rrange and trange. xrange and yrange affect the entire plot layout, not just the data.

Also note that you can move the origin on theta to the top using command set theta top. If you do this you need not add 90° to each data point.

Assuming that by "only the 2nd and 3rd quadrant" you mean 90 < theta < 270, your script becomes

set polar
set angle degrees
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 tics
unset key

r=1
set rrange [0:r]
set trange [ pi/2 : 3*pi/2 ]
set theta top

set rtics 0.166 format '' scale 0
set ttics (0,90,180) format "%g°"

plot 'exampleData.txt' using ($1):2 with lines

Note that I set trange in radians rather than degrees to work around the bug. Output using gnuplot 5.2.4 is attached enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • Thanks for your response Ethan, 'set theta top' command is very useful. However, the right half of the polar grid is displayed and I would like to have it hidden. Below Matt's post, Chris managed to display [only a half of the polar grid](https://i.stack.imgur.com/8Ozlb.png) which I really like. P.S., 1st quadrant = top, right; 2nd q. = top, left; 3rd q. = bottom left; 4th q. = bottom right. – Andrej Holúbek Sep 12 '18 at 10:46
  • I see what you mean about displaying only half of the circular grid. That doesn't seem to work any more. I will look into it further. – Ethan Sep 12 '18 at 18:01