3

I tried to draw a graph in the ggplot2 library with the addition of ggrepel:

set.seed(42)
ggplot(mtcars) +
  geom_point(aes(wt, mpg), size = 5, color = 'grey') +
  geom_label_repel(aes(wt, mpg, fill = factor(cyl), label = rownames(mtcars)),
                   fontface = 'bold', color = 'white',
                   box.padding = 0.35, point.padding = 0.5, 
                   segment.color = 'grey50') + 
  theme_classic(base_size = 16)

But I got the following error:

Error in convertUnit(x, unitTo, "x", "dimension", "x", "dimension", valueOnly = valueOnly) : 
  'x' argument must be a unit object

Thanks?

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Denmla
  • 135
  • 1
  • 8

1 Answers1

5

The error is caused by:

box.padding = 0.35, point.padding = 0.5

ggrepel version 0.6.11 was changed to accept numbers such as 0.35 or the returned value from unit(0.35, "lines").

If you're using ggrepel before version 0.6.11, then please try using:

unit(0.35, "lines"), unit(0.5, "lines")

My guess is that you're probably using ggrepel 0.6.5 from CRAN. You might consider updating to the latest version from CRAN, which is 0.7.0.

Kamil Slowikowski
  • 4,184
  • 3
  • 31
  • 39