Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Substitution for deprecated axis.ticks.margin in ggplot2 2.0

Tags:

plot

r

ggplot2

When using axis.ticks.margin in ggplot2 2.0, I got a Warning message:

axis.ticks.margin is deprecated. Please set margin property of axis.text instead.

I thought I could try axis.text.margin but I got another warning saying it was an invalid function. The release notes say:

The theme setting axis.ticks.margin has been deprecated: now use the margin property of axis.ticks.

So where is the margin setting now?

like image 722
Chuanxin Avatar asked Dec 30 '15 11:12

Chuanxin


1 Answers

See the ggplot 2.0 doc on theme:

axis.text

tick labels along axes (element_text; inherits from text)

This should be in an element_text element. Its doc points to function margin. Something along those lines should work:

+ theme(axis.text.x = element_text(margin=margin(5,5,10,5,"pt")),
        axis.text.y = element_text(margin=margin(5,5,10,5,"pt")))
like image 80
scoa Avatar answered Sep 19 '22 21:09

scoa