Skip to content

Bug: polar.plot interprets label.pos as radians #7

Description

@ugroempi

Thank you for maintaining the plotrix package after Jim Lemon's death.

There is a bug in the polar.plot function: labels are not placed correctly, because the degrees of the argument label.pos are interpreted as radians. Presumably, this came about with version 3.8-2 of the package (my 2022 material was still correct, because I did not update the package; in 2023, the labels became wrong).

It would be great if this could be fixed, which should be simple: swap lines 44 and 45 of radial.plot.R.

Best regards,
Ulrike

Demo code:

(tab <- table(10*sample(0:35, 1000,replace=TRUE, prob=((36:1)/sum(1:36)))))
tab <- tab/sum(tab)
## directions are wrong
## reason: label.pos are interpreted as radians,
##         contrary to historical behavior and documentation
polar.plot(matrix(tab,nrow=1), polar.pos=as.numeric(names(tab)),
           labels=c("N","NE","E","SE","S","SW","W","NW"),
           label.pos=seq(0,315,45), 
           start=90, clockwise=TRUE,    ## make directions follow conventions
           show.grid.labels=FALSE, 
           radial.lim=c(0, 1.1*max(tab)),
           main="Demo", rp.type="r", lwd=2)
## fix: provide label.pos in radians
##      should of course not be necessary
polar.plot(matrix(tab,nrow=1), 
           polar.pos=as.numeric(names(tab)),
           labels=c("N","NE","E","SE","S","SW","W","NW"),
           label.pos=seq(0,315,45)/180*pi, 
           start=90, clockwise=TRUE,
           show.grid.labels=FALSE, 
           radial.lim=c(0, 1.1*max(tab)),
           main="Demo", rp.type="r", lwd=2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions