Skip to contents

Degrees to text adjustment

Usage

degrees_to_adj(
  degrees,
  top = 90,
  clockwise = FALSE,
  expand = 0,
  bias_side = 3,
  bias_height = 1,
  plot_ranges = FALSE,
  ...
)

Arguments

degrees

numeric value for angles in degrees

top

numeric value indicating the angle at the top position

clockwise

logical indicating whether the angle increases in clockwise direction

expand

numeric value intended to expand the adjust value. For example expand=0.5 will expand the adjust value 50%.

...

additional arguments are ignored

Details

Utility function to define adj values suitable for text plotting, which arranges text relative to the angle in degrees.

Examples

degrees <- seq(from=1, to=360, by=15);
x <- cos(jamba::deg2rad(degrees));
y <- sin(jamba::deg2rad(degrees));
adjdf <- degrees_to_adj(degrees);
adjdf1 <- degrees_to_adj(degrees, bias_side=1, bias_height=1);
plot(x, y,
   pch=20, asp=1,
   xlim=c(-1.3, 1.3),
   ylim=c(-1.3, 1.3));
jamba::drawLabels(txt=seq_along(degrees),
   x=x, y=y, labelCex=0.8,
   adjX=adjdf1[,1], adjY=adjdf1[,2])
jamba::drawLabels(txt=seq_along(degrees),
   x=x, y=y, labelCex=0.8, boxColor="gold",
   adjX=adjdf[,1], adjY=adjdf[,2])

plot(x, y,
   pch=20, asp=1, cex=0.4, col="red",
   xlim=c(-1.3, 1.3),
   ylim=c(-1.3, 1.3));
for (i in seq_along(degrees)) {
   text(labels=i,
      x=x[i], y=y[i],
      adj=unlist(adjdf[i,]))
}