Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving directlabels slightly to left

I am trying to move my direct labels just slightly to the left, not one group but all groups. By default dl.move only moves one group at a time.

library(directlabels)
library(ggplot2)

count <- c(1,5,6,7,8,8)
year <- c(rep(c(2000,2001,2002),2))
group <- c(rep("A",3),rep("B",3))
c <- data.frame(year,count,group)

p <- ggplot(c, aes(x=year, y=count, colour=group)) + geom_line()

direct.label(p, "first.points")

I can move one point with...

kif <- dl.move("A", hjust=2, vjust=0)
direct.label(p, list("first.points",kif))

but I'd ideally just want to move the whole thing over a by the same hjust. Is there some silly syntax I've totally missed?

like image 587
Dan KS Avatar asked Oct 25 '25 09:10

Dan KS


2 Answers

dl.trans(x=x-0.1) moves everything to the left 0.1cm.

direct.label(p, list(dl.trans(x=x-0.1), "first.qp"))
like image 115
Toby Dylan Hocking Avatar answered Oct 27 '25 22:10

Toby Dylan Hocking


Found it. A simple

direct.label(p, list("first.points",hjust=2, vjust=0)) 

Not perfect but works, the spacing isn't uniform like default.

like image 27
Dan KS Avatar answered Oct 27 '25 23:10

Dan KS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!