rotate the gnuplot raxis label to 45 degrees without rtics

Viewed 122

I have a polar plot in Gnuplot given by

set polar
set angles degrees
unset xtics
unset ytics
unset raxis
set ttics 0,30
set grid polar linestyle 1 dashtype 2 linecolor rgb 'grey'
set samples 200, 200
unset border

set xrange [-0.51:0.51]
set yrange [-0.51:0.51]
set size square
unset key

plot sin(2*t)*cos(2*t)

Which gives the following output:

Polar plot

However,

  1. I want the rlabels (0, 0.1, 0.2, etc) at an angle of 45 degrees instead of them being placed on the x-axis, and
  2. There should be no rtics

Any help will be appreciated.

2 Answers

In order to remove the rtics do set rtics scale 0.

You can set the starting angle for polar graph (check help theta), however, only to {right|top|left|bottom} and not to 45°, but this still wouldn't help you here. So, probably you have to set the labels "manually". Maybe there is an automatic way which I am not aware of. Check the following example.

Code:

### set rtics on 45° "axis"
reset session

set polar
set angles degrees
unset xtics
unset ytics
unset raxis
set ttics 0,30
set grid polar linestyle 1 dashtype 2 linecolor rgb 'grey'
set samples 200, 200
unset border

set xrange [-0.51:0.51]
set yrange [-0.51:0.51]
set size square
unset key
set rtics scale 0
set format r ""

myRTics = "0.1 0.2 0.3 0.4 0.5"
do for [i=1:words(myRTics)] {
    r = word(myRTics,i)
    set label i sprintf("%s",r) at r*cos(45),r*sin(45) center
}
plot sin(2*t)*cos(2*t)
### end of code

Result:

enter image description here

I addition to @theozh's excellent answer, I realized I can generate the labels on the fly, by providing the start, end, and increment of the labels. So instead of

myRTics = "0.1 0.2 0.3 0.4 0.5"
do for [i=1:words(myRTics)] {
    r = word(myRTics,i)
    set label i sprintf("%s",r) at r*cos(45),r*sin(45) center
}

I will write

rangle = 45
rstart = 0.1 ; rend = 0.5 ; rinc = 0.1 ;
n = floor((rend-rstart)/rinc) + 1

do for [i=1:n] {
    r = rstart + (i-1)*rinc
    set label i sprintf("%g",r) at r*cos(rangle),r*sin(rangle) center
}

The rest of it will be as already answered by @theozh. The output doesn't change.

I am a bit surprised that Gnuplot doesn't have any inbuilt method to handle this.

Related