1

I want to customize the labels of a polar.plot in R.

I have the following plot:

polar.plot(lengths = 0.4, polar.pos =33, 
           main= "Richting en magnitude van de waterstroom", labels = ?, 
           start=90, clockwise = TRUE, loglen=FALSE, explab=FALSE, 
           rp.type="r", lwd = 4, line.col = "blue")

I want to add custom labels to the outer circle, with certain values at certain degrees and nothing else.

the labels are:

c("t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8")

and the angles would be every 45 degrees, so:

c(0,45,90,135,180,225,270,315)

However, I can't seem to find out how to correctly format this to fill it in the argument 'labels = x' in the plot. i have treid filling in the labels string under labels = x and the angles string under label.pos = x as follows:

(colnames = c("t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8"))

polar.plot(lengths = magnitude, polar.pos =degrees, 
           main= "Richting en magnitude van de waterstroom", 
           labels = colnames, 
           label.pos = c(0,45,90,135,180,225,270,315), 
           start=90, clockwise = TRUE, loglen=FALSE, explab=FALSE, 
           rp.type="r", lwd = 4, line.col = "blue") 

However, this does not give the desired effect. the labels are all there, and t1 is at 0 degrees, but after that something goes wrong.

1 Answers1

1

You could specify the position of the labels using label.pos and you should divide the numbers by (180/pi) like this:

positions of the peripheral labels in degrees

Code:

library(plotrix)
polar.plot(lengths = 0.4, polar.pos=33, 
           main= "Richting en magnitude van de waterstroom", 
           labels = c("t1", "t2", "t3", "t4", "t5", "t6", "t7", "t8"), 
           label.pos = c(0,45,90,135,180,225,270,315)/(180/pi),
           start=90, clockwise = TRUE, 
           loglen=FALSE, explab=FALSE, 
           rp.type="r", lwd = 4, line.col = "blue")

Created on 2022-08-15 by the reprex package (v2.0.1)

Quinten
  • 35,235
  • 5
  • 20
  • 53
  • Thanks Quinten, I just tried this myself and got the exact same outcome as you did. However, the given image is not my desired outcome, as the labels are not given at every 45 degrees. How can I solve that? – Djingleberg Aug 15 '22 at 11:39
  • 1
    @Djingleberg, After diving into the code, I found that you should divide your angels by (180/pi) As in my answer above. – Quinten Aug 15 '22 at 12:42