move all directlabels

2019-07-21 07:26发布

I am using directlabels for the first time today and as this is a new package the documentation is pretty sparse still. I have created a faceted density plot similar to this data and the labels could all be moved up and slightly right.

If this were mtext I could use adj and padj to move the text around. How would I do the same to the labels below. Move every label slightly up and slightly right?

library(directlabels); library(ggplot2)
g <- ggplot(CO2, aes(x=conc, group=Type))
h <- g + geom_density(aes(colour=Type)) +facet_grid(Treatment~.)
direct.label(h)

This is the last bit until I have a figure ready for publication and so help here would be much appreciated.

EDIT The top.bumptwice doesn't move the text up quite enough. I would like more control over the move.

标签: r ggplot2
1条回答
我想做一个坏孩纸
2楼-- · 2019-07-21 08:21

I asked the author and you can pass the moves to direct.labels as a list:

library(ggplot2); library(directlabels)
x <- ggplot(CO2, aes(x=uptake, group=Plant))
y <- x + geom_density(aes(colour=Plant)) + 
    facet_grid(Type~Treatment)+ theme_bw()
y 


my.method1 <- list('top.points',dl.move("Qn1",  hjust=0,vjust=-5) 
)


direct.label(y, my.method1)
查看更多
登录 后发表回答